Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Can I pass control to a 2nd workbook

Apologies if this message is a near repeat of one I wrote earlier -
the earlier message woould appear to have been consigned to
hyperspace!

How can I, or indeed is it possible, to call a macro in a second
workbook and pass to it the value of a variable - in this case the
name of the 1st workbook?

The code that I have been trying to 'debunk' is:

Sub CallResultsAnalyser()

Dim ThisWb As String
Dim ResAnalysis As String

ThisWb = ActiveWorkbook.Name
ResAnalysis = "p:\results analyser.xls"

' Open the results analyser if it isn't already open
On Error Resume Next
Application.Workbooks.Open (ResAnalysis)
On Error GoTo 0

Application.Run ("'Results Analyser.xls'Main!AnalyseResults",ThisWb)

End Sub

It's the last line that is causing the problem: I am trying to run the
macro AnalyseResults(byval ThisWb as String) in the workbook Results
Analyser.xls ... can it be done? Is there a better way?

Thanks in anticipation ... even if the answer is bad news.

Alan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Can I pass control to a 2nd workbook

think you just have a typo in your run command

Application.Run ("'Results Analyser.xls'Main!AnalyseResults",ThisWb)


should be

Application.Run ("'Results Analyser.xls!Main.AnalyseResults",ThisWb)

This assume the macro AnalyseResults is located in a general/standard module
named "Main" in the Results Analyser.xls workbook and it is declared to take
a string argument.

Public Sub AnalyseResults( s as String)

--
Regards,
Tom Ogilvy


"Alan" wrote:

Apologies if this message is a near repeat of one I wrote earlier -
the earlier message woould appear to have been consigned to
hyperspace!

How can I, or indeed is it possible, to call a macro in a second
workbook and pass to it the value of a variable - in this case the
name of the 1st workbook?

The code that I have been trying to 'debunk' is:

Sub CallResultsAnalyser()

Dim ThisWb As String
Dim ResAnalysis As String

ThisWb = ActiveWorkbook.Name
ResAnalysis = "p:\results analyser.xls"

' Open the results analyser if it isn't already open
On Error Resume Next
Application.Workbooks.Open (ResAnalysis)
On Error GoTo 0

Application.Run ("'Results Analyser.xls'Main!AnalyseResults",ThisWb)

End Sub

It's the last line that is causing the problem: I am trying to run the
macro AnalyseResults(byval ThisWb as String) in the workbook Results
Analyser.xls ... can it be done? Is there a better way?

Thanks in anticipation ... even if the answer is bad news.

Alan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Can I pass control to a 2nd workbook

Check your other post, too.

Alan wrote:

Apologies if this message is a near repeat of one I wrote earlier -
the earlier message woould appear to have been consigned to
hyperspace!

How can I, or indeed is it possible, to call a macro in a second
workbook and pass to it the value of a variable - in this case the
name of the 1st workbook?

The code that I have been trying to 'debunk' is:

Sub CallResultsAnalyser()

Dim ThisWb As String
Dim ResAnalysis As String

ThisWb = ActiveWorkbook.Name
ResAnalysis = "p:\results analyser.xls"

' Open the results analyser if it isn't already open
On Error Resume Next
Application.Workbooks.Open (ResAnalysis)
On Error GoTo 0

Application.Run ("'Results Analyser.xls'Main!AnalyseResults",ThisWb)

End Sub

It's the last line that is causing the problem: I am trying to run the
macro AnalyseResults(byval ThisWb as String) in the workbook Results
Analyser.xls ... can it be done? Is there a better way?

Thanks in anticipation ... even if the answer is bad news.

Alan


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Can I pass control to a 2nd workbook

Thanks guys. I had all but given up on the two messages that I had
posted: for whatever reason I couldn't see either of them on my
machine for the first 48 hours after posting!

Reply
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
pass variable from one workbook to another calebjill Excel Discussion (Misc queries) 2 January 28th 09 07:38 PM
Pass control back to Excel window [email protected] Excel Worksheet Functions 1 December 29th 06 07:24 PM
pass workbook name to sub Przemek Excel Programming 1 August 11th 05 04:09 PM
How to pass interior colours of specified range to a control. ExcelMonkey Excel Programming 5 July 27th 05 12:53 PM
How to Pass Control from VBA to user and return needyourhelp Excel Programming 3 June 7th 05 12:53 PM


All times are GMT +1. The time now is 06:53 PM.

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"