Question Microsoft Web Browser - Error handling

MikeDuffield

Registered User.
Local time
Today, 21:02
Joined
Aug 31, 2010
Messages
50
Hello all,

I have a quick question which I'm sure a lot of you will know the answer to straight away...

A database I am developing displays PDF files in a web browser that is on a form. If the PDF file exists, all well and good - users can print, email it etc. If the PDF file doesn't exist then it obviously displays "Page cannot be found" or similar error message.

Is there a way to make the web browser not visible when this happens?

Thanks in advance,
Mike.
 
Mike,
I did some searching after seeing your post. I found this function, and I have tested it with some files and directories on my PC. I have reformatted slightly, but did keep the author's name.
Code:
'---------------------------------------------------------------------------------------
' Procedure : FileFolderExists
' Author    : Ken Puls (www.excelguru.ca)
' Purpose   : Check if a file or folder exists
'---------------------------------------------------------------------------------------
'
Public Function FileFolderExists(strFullPath As String) As Boolean

   On Error GoTo FileFolderExists_Error

   If Not dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
    
EarlyExit:
    
   On Error GoTo 0
   Exit Function

FileFolderExists_Error:

    MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure FileFolderExists of Module AWF_Related"

End Function

You could check if the file exists, and then make the browser visible True/False accordingly.

if filefolderexists("YourpathandFileName") = True then
yourBrowserControl.visible = true
else
yourBrowserControl.visible = false
end if
 
Ah brilliant, I hadn't thought about checking the file status before loading it - great idea!

Thanks for your help!
 

Users who are viewing this thread

Back
Top Bottom