Open existing workbook

  • Thread starter Thread starter Daniel Van Eygen
  • Start date Start date
D

Daniel Van Eygen

Hi all experts,
I have a set (3) of workbooks that open from a shortcut on the desktop. When
the workbooks are open I want to give the user the possibility to open an
already existing workbook to replace one of the open workbooks (the one on
the button to open an existing book) and leave the 2 other workbooks that
are already open. So the user needs to see a windows file list to choose
from, select a file and than the macro should run further.
I have no idea on how to start on this.
Thanks for any valued help.
Daniel
 
hi,
here is a way to call the open dialog box.

Application.Dialogs(xlDialogOpen).Show

You can work it into your code.
reguards.
 
Not real clear on your situation, but to show the file Open dialog

Dim fName as Variant
chDrive "C"
chDir "C:\MyFolder"
fName = Application.GetOpenFileName()
if fName <> False then
workbooks.open fName
End if

The dialog returns the name and path of the file chosen - it doesn't open
it. So you have to open it with workbooks.Open.
 
Thanks Frank,
I did some experimenting and came up with this code:

Private Sub CommandButton18_Click()
ChDir "c:\Dunrail\Projects"
Workbooks.Open Application.GetOpenFilename
ChDir "c:\Dunrail"
End Sub

This works fine as long as I select a file. If I hit "cancel" instead I get
an error. How can I trap the error in order to avoid the error message?

Daniel.
 

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