Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running macros under different workbook names?

Status
Not open for further replies.

boyracer3000

Programmer
Mar 1, 2002
3
NL
I have set up my workbook to run this nested macro:

Application.Run "'week-template.xls'!InsertRow"

Now I realise when saving the workbook under a different name this isn't going to work anymore. Is there a different way of coding this so that it will work. I'm thinking maybe to just pull the code out and paste into the macro it's currently in. Any ideas?
 
Hi,

You define a workbook object and set it to the workbook in question...
Code:
Dim wbkTemplate As Workbook

Set wbkTemplate = Workbooks("YourNewName.xls")

Application.Run "'" & wbkTemplate"'!InsertRow"
Seems to me that this should work. :) Skip,
metzgsk@voughtaircraft.com
 
Actually, this works...
Code:
    Dim wbkTemplate As Workbook
    Set wbkTemplate = Workbooks("TimeCard.xls")
    
    Application.Run wbkTemplate.Name & "!CopyRow"
:) Skip,
metzgsk@voughtaircraft.com
 
Awesome I'll try this when I get home. Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top