Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing filename to macro

1 view
Skip to first unread message

Alfred

unread,
Oct 18, 2010, 8:20:40 AM10/18/10
to
I am recording a macro that will copy found data from one file into
another file.

The second file will always have the same name, but the first file
will always be different.

I'm looking in the VBA code, and it is specifying each file by name.

I was wondering if there is a way to pass the current open file
(a .rtf file) to the macro so it will switch back to that file after
it is done pasting, thereby setting the macro up for the next
iteration.

Here's the code so far:

Sub OBJECTGET()
'
' OBJECTGET Macro
' Macro recorded 3/24/2008 by me
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "OBJ:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Windows("NonVariableFile").Activate
Selection.Paste
Windows("VariableFile").Activate

Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub

I want to replace the "VariableFile" with a string (or something) that
always gets the open file I'm currently using. I hope that makes
sense.

Al

0 new messages