running macro in different workbook

running macro in different workbook

running macro in different workbook

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

RE: running macro in different workbook

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.

RE: running macro in different workbook

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.

RE: running macro in different workbook

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

RE: running macro in different workbook

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.

RE: running macro in different workbook

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).