Selecting Workbooks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After getting the user to select the file to open by:
fName = Application.GetOpenFilename
Workbooks.Open Filename:=fName
Any idea how can i refer to this workbook again later on in my code?
 
Hi Darren

as long as you don't redefine fName

Workbooks(fName).Activate
or
Workbooks(fName).Sheets("Sheet1").Select
etc

Cheers
JulieD
 
dim wb as workbook

fName = Application.GetOpenFilename
set wb=workbooks.open(fName)


Tim
 
Watch out.

fName will include the drive\path when it comes back from .getopenfilename.

You could strip the drive\path out of the string, or use a variable like Tim
suggested.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top