LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Passing variables between excel files

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 Auto_Open macro in Wkbk. In that macro I want to say
- for example depending on certain conditions: varMyTestNumber = -1 and then
when the Wkbk Auto_Open 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing excel cell values as sql variables jai[_2_] Excel Programming 4 December 28th 06 09:41 AM
Passing Variables-Excel VBA trini Excel Programming 2 February 17th 05 07:05 PM
passing variables Squid[_2_] Excel Programming 1 July 27th 04 03:47 AM
Passing Excel formats in VBA date variables ExcelMonkey[_54_] Excel Programming 3 January 31st 04 10:40 PM
passing variables from excel to word Mike NG Excel Programming 8 July 22nd 03 12:08 PM


All times are GMT +1. The time now is 06:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"