Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Passing values to new app

I have some public variables defined in an Excel97 macro which I would
like to pass to a different macro. They are "strTempFileName" and
"strTempFilePath". I use the following code to to start the new macro:

Application.OnTime.Now, "MacroFile2.xls!Module1"

Is there a way to pass the values to the new macro when I start it?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Passing values to new app

Better to make the Onetime macro a macro in the same workbook, and then use
Application.Run from within this macro to fire the macro in the other
workbook.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"BrianG" wrote in message
...
I have some public variables defined in an Excel97 macro which I would
like to pass to a different macro. They are "strTempFileName" and
"strTempFilePath". I use the following code to to start the new macro:

Application.OnTime.Now, "MacroFile2.xls!Module1"

Is there a way to pass the values to the new macro when I start it?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Passing values to new app

Brian,

Rather than use OnTime, use Run. This allows you to pass up to 29
parameters. E.g,

Application.Run "'Book3.xls'!AAA", "this is a test"

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"BrianG" wrote in message
...
I have some public variables defined in an Excel97 macro which

I would
like to pass to a different macro. They are "strTempFileName"

and
"strTempFilePath". I use the following code to to start the

new macro:

Application.OnTime.Now, "MacroFile2.xls!Module1"

Is there a way to pass the values to the new macro when I start

it?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Passing values to new app

Thanks for the help! Two questions though...
1) Will Application.Run close the first workbook(I'm thinking that's why
I used .OnTime.Now)? Part of the purpose of the 2nd workbook macro is
to delete the macros and vb components in the first wookbook.
2)I'm confused as to whether I can pass the variable name as the
parameter of if I need to pass the value. Would this work...

Sub Main()
Dim strTempFileName as String
Dim strTempFilePath as String
strTempFileName = ActiveWorkbook.Name
strTempFilePath = Environ("temp")
..
..
..
Application.Run "'MacroFile2.xls'!Module1", strTempFileName_
,strTempFilePath
End Sub

In MacroFile2.xls
Sub Module1(strTempFileName as String, strTempFilePath as_ String)
..
..
..
End Sub

--
BrianG


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
passing values to other sheets [email protected] New Users to Excel 1 February 23rd 08 02:03 AM
Passing values in Sheet to VBA Jonathan Charts and Charting in Excel 1 June 30th 06 06:00 AM
Hyperklinks - passing values Nigel[_7_] Excel Programming 0 February 18th 04 10:23 AM
Passing values between 2 subs ? [email protected] Excel Programming 1 November 21st 03 05:56 PM
passing values from one sheet to another BubBob[_2_] Excel Programming 1 September 4th 03 01:09 PM


All times are GMT +1. The time now is 05:59 PM.

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

About Us

"It's about Microsoft Excel"