Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

running macro in different workbook

Status
Not open for further replies.

LonnieP

Structural
Oct 20, 2009
80
I need to run a macro that's in a closed workbook. The complete filespec is in cell W6 of the active sheet. The macro name is HIGHLITE. I'd like to do this without actually opening the workbook. Is this possible? If so some code would help a lot.

Thanks, LonnieP
 
Replies continue below

Recommended for you

I won't say it's impossible, because many unexpected things can be done by various devious tricks, but certainly the easiest way would be to open the file. That could be done in the background with VBA, and it could be automatically closed when you are finished, so the user wouldn't need to be aware of it at all.

Doug Jenkins
Interactive Design Services
 
Doug, You're right. That's how I got the working range out of the source file to begin with, and ran the link-up macros while the file was minimized. Just hoping there was a simple way of doing it 'in the dark'. It all happens so fast it won't really make that much difference anyway.

Maybe someone out there can give a definite Yes or No on this.

LonnieP
 
If Doug doesn't know, then the odds of it existing are pretty slim.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Walkenbach's book does indicate it can be done with something having to do with "References". I'm giving up on this, for now, because I've found a 'work around' that doesn't need Visual Basic, and should be more intuitive to the user.

LonnieP
 
I'm still a bit curious as to why you want to run a macro in a closed workbook.

The procedure for adding VBA references given by John Walkenbach (I'm looking at Excel 2002 Power Programming with VBA) is probably the easiest way to use a macro in a different workbook, but strictly speaking the referenced workbook is no longer closed once you have created the reference. The file doesn't need to be open to create the reference, but when it is created the file is automatically opened. If you link to a standard Excel file (.xls, xlsm, or xlsb) the file will be accessible after the reference is completed, just like any other open workbook. If you link to an add-in file (xla or xlam) the worksheets will be hidden, but the file will still be there in the background, and the VBA code will be accessible, unless it has been locked and protected.

Doug Jenkins
Interactive Design Services
 
I'm porting over my Lotus calc system to Excel. Now that I'm retired I have the time to fool with it.

My system is based on small spreadsheets that can be stacked together, kind of like Legos. Sometimes I need to move, copy or delete a module but due to most of it being 'off screen', painting the range manually is too cumbersome. However, it's possiblle to make a VB macro that can paint the proper range. The down side is few of the blocks (modules) are the same size and the 100% solution would be to have the copy/move/delete macros in the module file itself, to be called when needed (hopefully without needing to actually open the file).
 
I can't tell which version you're using, but it's possible, I think, to put macros into the Excel startup file, and that should make them available to any open worksheet.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor