I am trying to pass a Variable between Macros (Main and Analog) in MS-Word.
The user enters a Number in the message box. This is used to open multiple
Files that start with this number.
The Complete filename are: 123456_Analog65.txt and 123456_Digtial65.txt
etc...
This is only a small part of a large macro I want to use on multiple files
Example Macro:
Sub Main()
Dim Message, Title, Default
Dim Cmr As String
Message = "Enter New File Name:" ' Set prompt.
Title = "File Will be saved with this Name" ' Set title.
Default = " " ' Set default.
Cmr = InputBox(Message, Title, Default)
Application.Run MacroName:="Analog"
Application.Run MacroName:="Digital"
end sub
Sub Analog()
Dim MyRawData As String
Dim MyReconfiguredData As String
Underscore = "_"
Rawdir = "C:\"
Rawdata = "Analog65.txt"
MyRawData = Rawdir + Cmr + Underscore + Rawdata
MyReconfiguredData = "Analog65.txt"
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:=MyRawData, ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto
Selection.Find.ClearFormatting
With Selection.Find
.Text = "H500: AMO SCSU STARTED"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
end sub
Any assistance will be greatly appreciated
Doug Robbins - Word MVP - 24 Mar 2007 17:17 GMT
See response to your post with the subject "MS-Word 2003 VBA Variable
Question" in the vba.general newsgroup.
Please do not post the same question separately to multiple newsgroups.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I am trying to pass a Variable between Macros (Main and Analog) in MS-Word.
> The user enters a Number in the message box. This is used to open
[quoted text clipped - 46 lines]
>
> Any assistance will be greatly appreciated
VexedFist - 28 Mar 2007 02:55 GMT
Doug,
I already had the text you supplied below in my MAIN macro.
The problem I have is when I run the sub macros,
that put the file names together I get teh following ERROR.
Run Time Error 5174
This file could not be found
Try one or more of the following:
* Check the spelling of the name of the document
* Try a different file name.
(C:\_Analog65.txt)
Your assistance in this matter will be greatly appreciated.
> Sub Analog()
> Dim MyRawData As String
[quoted text clipped - 10 lines]
> _
> end sub
The problem I get is an ERROR when using CMR 123456, see below:
> See response to your post with the subject "MS-Word 2003 VBA Variable
> Question" in the vba.general newsgroup.
[quoted text clipped - 51 lines]
> >
> > Any assistance will be greatly appreciated
Doug Robbins - Word MVP - 28 Mar 2007 16:17 GMT
Have you declared CMR as Public?

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Doug,
>
[quoted text clipped - 91 lines]
>> >
>> > Any assistance will be greatly appreciated