View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default switching workbooks using variable and wilcard filename

I still think it's best to prompt the user for the file. Mike suggests
listing the open workbooks and so you could put their names in a
listbox for the user to select. Of course, if there's only 2 files open
then no need to prompt the user because one file will be your VBA file
and the other one will be the file you're after. (Assumes user did not
close or the file already)

Otherwise, your VBA file should not be included in the list.<g

IMO, this would be easier to manage if your VBA file is an Addin (XLA)
and already running whenever Excel opens. Custom menus can be added to
give users access to your macros, which could set a reference to the
ActiveWorkbook as the target file for processing.

Example:
Set wkbTarget = ActiveWorkbook
With wkbTarget
'..do stuff
End With 'wkbTarget

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc