Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA Apllication.run and macros when spreadsheet name changes

How can change the following statement to run a macro so I do not have to
change the spreadsheet name every time it changes.

Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove"

'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would
just like the statement to run the macro Midmonthnumbersmove no matter what
the spreadsheet name is.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default VBA Apllication.run and macros when spreadsheet name changes

if this is the active workbook, you don't need the spreadsheet name. is this
in some other workbook?

--


Gary


"newguyoldguy" wrote in message
...
How can change the following statement to run a macro so I do not have to
change the spreadsheet name every time it changes.

Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove"

'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would
just like the statement to run the macro Midmonthnumbersmove no matter
what
the spreadsheet name is.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default VBA Apllication.run and macros when spreadsheet name changes

You can call a macro from an open workbook using....

Call Midmonthnumbersmove


--
Cheers
Nigel



"newguyoldguy" wrote in message
...
How can change the following statement to run a macro so I do not have to
change the spreadsheet name every time it changes.

Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove"

'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would
just like the statement to run the macro Midmonthnumbersmove no matter

what
the spreadsheet name is.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA Apllication.run and macros when spreadsheet name changes

If it is always referring to the activeworkbook, you could use

Application.Run "'" & Activeworkbook.Name & "'!Midmonthnumbersmove"


but better would be to set a object variable to the book when you open it,
and use that

Set oWB = Activewrokbook

...

Application.Run "'" & oWB.Name & "'!Midmonthnumbersmove"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"newguyoldguy" wrote in message
...
How can change the following statement to run a macro so I do not have to
change the spreadsheet name every time it changes.

Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove"

'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would
just like the statement to run the macro Midmonthnumbersmove no matter

what
the spreadsheet name is.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default VBA Apllication.run and macros when spreadsheet name changes

Bob,

Why is your way better? What if the workbook was saved with an other name
after opening?

Please explain.

Grtz,

Rody









"Bob Phillips" schreef in bericht
...
If it is always referring to the activeworkbook, you could use

Application.Run "'" & Activeworkbook.Name & "'!Midmonthnumbersmove"


but better would be to set a object variable to the book when you open it,
and use that

Set oWB = Activewrokbook

...

Application.Run "'" & oWB.Name & "'!Midmonthnumbersmove"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"newguyoldguy" wrote in message
...
How can change the following statement to run a macro so I do not have to
change the spreadsheet name every time it changes.

Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove"

'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would
just like the statement to run the macro Midmonthnumbersmove no matter

what
the spreadsheet name is.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA Apllication.run and macros when spreadsheet name changes

Works great! thank you very much for your help!

"newguyoldguy" wrote:

How can change the following statement to run a macro so I do not have to
change the spreadsheet name every time it changes.

Application.Run "'Salesman pay 2.9.xls'!Midmonthnumbersmove"

'Salesman pay 2.9.xls' is the spreadsheet name in this example. I would
just like the statement to run the macro Midmonthnumbersmove no matter what
the spreadsheet name is.


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
Trying to save spreadsheet with macros??????? Buggsthecat1 Excel Discussion (Misc queries) 0 May 12th 10 03:11 PM
How can I complete a spreadsheet using macros? Walter Heijboer Excel Worksheet Functions 1 July 23rd 05 02:27 PM
How can I complete a spreadsheet using macros? Walter Heijboer Excel Discussion (Misc queries) 1 July 23rd 05 01:36 PM
Copying a spreadsheet with macros WayneB Excel Worksheet Functions 4 March 12th 05 11:19 PM
Apllication.OnTime Mischa Browne[_2_] Excel Programming 8 July 14th 04 08:04 PM


All times are GMT +1. The time now is 09:46 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"