S
Steven
I tried to figure this out and looked through this website but do not get it.
In the following code there is a Workbook set to Wkbk. After Wkbk opens the
next line is to run the Autpen macro in Wkbk. In that macro I want to say
- for example depending on certain conditions: varMyTestNumber = -1 and then
when the Wkbk Autpen macro completes and returns to this macro I want to
be able to say:
If varMyTestNumber = -1 Then
"Code to run"
Else
"Run this code"
Endif
1) I cannot get a variable to return back from the Wkbk file. How do I do
this?
Another question:
2) How would I call a different macro in Wkbk file. I tried using
Application.Run but it keeps telling me it cannot find the macro. The other
macro is called "Private Sub GetPassCodeNumber()
Thank you,
Steven
'-------------------------------------------------------------------------------------------
Sub Tester()
Dim Wkbk As Workbook
Dim myFileName As String
Dim myPath As String
Application.ScreenUpdating = False
myPath = "C:\" '<- include that backslash!
myFileName = "Book1.xls"
Set Wkbk = Nothing
On Error Resume Next
Set Wkbk = Workbooks(myFileName)
On Error GoTo 0
If Wkbk Is Nothing Then
'it's not open
Set Wkbk = Workbooks.Open(Filename:=myPath & myFileName, _
UpdateLinks:=False, ReadOnly:=False, Password:="aoaoao")
Wkbk.RunAutoMacros which:=xlAutoOpen
Else
MsgBox "The file is already open!"
End If
'*** I am getting nothing here ***'
If varMyTestNumber = -1 Then
"Code to run"
Else
"Run this code"
Endif
End Sub
In the following code there is a Workbook set to Wkbk. After Wkbk opens the
next line is to run the Autpen macro in Wkbk. In that macro I want to say
- for example depending on certain conditions: varMyTestNumber = -1 and then
when the Wkbk Autpen macro completes and returns to this macro I want to
be able to say:
If varMyTestNumber = -1 Then
"Code to run"
Else
"Run this code"
Endif
1) I cannot get a variable to return back from the Wkbk file. How do I do
this?
Another question:
2) How would I call a different macro in Wkbk file. I tried using
Application.Run but it keeps telling me it cannot find the macro. The other
macro is called "Private Sub GetPassCodeNumber()
Thank you,
Steven
'-------------------------------------------------------------------------------------------
Sub Tester()
Dim Wkbk As Workbook
Dim myFileName As String
Dim myPath As String
Application.ScreenUpdating = False
myPath = "C:\" '<- include that backslash!
myFileName = "Book1.xls"
Set Wkbk = Nothing
On Error Resume Next
Set Wkbk = Workbooks(myFileName)
On Error GoTo 0
If Wkbk Is Nothing Then
'it's not open
Set Wkbk = Workbooks.Open(Filename:=myPath & myFileName, _
UpdateLinks:=False, ReadOnly:=False, Password:="aoaoao")
Wkbk.RunAutoMacros which:=xlAutoOpen
Else
MsgBox "The file is already open!"
End If
'*** I am getting nothing here ***'
If varMyTestNumber = -1 Then
"Code to run"
Else
"Run this code"
Endif
End Sub