G
Guest
Here are the two (simplest!) versions that work:
A) variable myOptFile declared / assigned at the module-level
.....Const myOptFile As String = "Test.xls"
---------------------------------------------------------
Sub macro1 ()
....................................
.....Call myMacro(myOptFile)
...................................
End Sub
-------------------------------------------------------
Sub myMacro (OptFile)
............................................
.....Windows( OptFile ).Activate
............................................
End Sub
------------------------------------------------------------------------------------------------
B) variable myOptFile assigned to ThisWorkbook.Name
.....Public myOptFile As String
------------------------------------------------------
Sub macro1 ()
....................................
.....Call myMacro(myOptFile)
...................................
End Sub
------------------------------------------------------
Sub myMacro (OptFile)
............................................
.....Windows( OptFile ).Activate
............................................
End Sub
------------------------------------------------------
Private Sub Workbook_Open()
............................................
.....myOptFile = ThisWorkbook.Name
............................................
End Sub
Thank you all for your tremendous help.
A) variable myOptFile declared / assigned at the module-level
.....Const myOptFile As String = "Test.xls"
---------------------------------------------------------
Sub macro1 ()
....................................
.....Call myMacro(myOptFile)
...................................
End Sub
-------------------------------------------------------
Sub myMacro (OptFile)
............................................
.....Windows( OptFile ).Activate
............................................
End Sub
------------------------------------------------------------------------------------------------
B) variable myOptFile assigned to ThisWorkbook.Name
.....Public myOptFile As String
------------------------------------------------------
Sub macro1 ()
....................................
.....Call myMacro(myOptFile)
...................................
End Sub
------------------------------------------------------
Sub myMacro (OptFile)
............................................
.....Windows( OptFile ).Activate
............................................
End Sub
------------------------------------------------------
Private Sub Workbook_Open()
............................................
.....myOptFile = ThisWorkbook.Name
............................................
End Sub
Thank you all for your tremendous help.