MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Open Excel Workbook

Posted by Ben on September 22, 2001 1:21 AM

how do i create a code to open an excel workbook?

Posted by Tom Urtis on September 22, 2001 9:16 AM

I assume you want to do this with VBA also as with your next post. Here's a simple code example that opens a file, or to avoid a run time error alerts you that no such file exists.

Sub OpenFile()
On Error Resume Next
Application.Workbooks.Open "C:\My Documents\YourFileName.xls"
If Err Then MsgBox "No such file."
Err = 0
On Error GoTo 0
End Sub

Tom Urtis