MyFlight
Technical User
- Feb 4, 2002
- 193
I am trying to pass a Variable between Macros (Main and Analog) in MS-Word.
The user enters a Number (Cmr) 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
Rawdir = "C:\"
Rawdata = "_Analog65.txt"
MyRawData = Rawdir + Cmr +Rawdata
MyReconfiguredData = "Analog65.txt"
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:=MyRawData, ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto
end sub
The Main Problem is how to use the Variable (Cmr) from another Macro (Analog).
Any assistance will be greatly appreciated
The user enters a Number (Cmr) 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
Rawdir = "C:\"
Rawdata = "_Analog65.txt"
MyRawData = Rawdir + Cmr +Rawdata
MyReconfiguredData = "Analog65.txt"
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:=MyRawData, ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto
end sub
The Main Problem is how to use the Variable (Cmr) from another Macro (Analog).
Any assistance will be greatly appreciated