Thread: Get filename
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Get filename

One way:

Dim wbBook1 As Workbook
Dim wbBook2 As Workbook
Dim vFileName As Variant
Set wbBook1 = ActiveWorkbook
vFileName = Application.GetOpenFilename
If vFileName = False Then Exit Sub
Set wbBook2 = Workbooks.Open(Filename:=vFileName)

Then use

wbBook2.Activate

and

wbBook1.Activate

to switch.



In article ,
"Tang" wrote:

i use getopenfilename to get a excel file and open it, and copy certain
range within 2 files.

my problem is i don't know how to switch within 2 windows.

i try to use workbook(filename).activate, but the filename variable include
the path as well.

regards