Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to handle open file errors in code?

I've got an excel workbook that opens another file using:

On Error GoTo Missing
Workbooks.Open Filename:=fn, UpdateLinks:=False, ReadOnly:=True

When the file can't be opened, I'd like the code to handle the
situation. However, if the file can't be open, the user still gets a
pop-up saying the file can't be opened, do you want to continue?

Is there any way to supress that message to the user?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How to handle open file errors in code?

Dim wbkOpen As Workbook

On Error Resume Next
Set wbkOpen = Workbooks.Open(Filename:=fn, UpdateLinks:=False, _
ReadOnly:=True)
On Error GoTo 0

If wbkOpen Is Nothing Then
If MsgBox("file did not open. continue?", vbYesNo) = vbNo Then
MsgBox "All done"
Else
MsgBox "Keep on going"
End If
End If
--
HTH...

Jim Thomlinson


"M. Brane" wrote:

I've got an excel workbook that opens another file using:

On Error GoTo Missing
Workbooks.Open Filename:=fn, UpdateLinks:=False, ReadOnly:=True

When the file can't be opened, I'd like the code to handle the
situation. However, if the file can't be open, the user still gets a
pop-up saying the file can't be opened, do you want to continue?

Is there any way to supress that message to the user?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Excel Discussion (Misc queries) 0 April 23rd 09 08:53 PM
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Setting up and Configuration of Excel 0 April 23rd 09 08:53 PM
Error Handle: File is already open. J@Y Excel Programming 3 July 17th 07 08:22 PM
Handle Compile Errors JeffT Excel Programming 1 October 14th 04 01:38 PM
REPOST: How to handle errors Bob Kilmer Excel Programming 0 August 5th 03 11:24 PM


All times are GMT +1. The time now is 11:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"