Webbrowser Control problems on form (1 Viewer)

laserfx

New member
Local time
Today, 01:58
Joined
Apr 1, 2011
Messages
4
Hi, I hope someone might be able to help.
This is the first time I have used the web-browser control in a form. I used this control as I wanted to view a pdf file within the form, and saw a You-tube video showing how to use the web browser. I had previously tried an Active X control, but that just didn’t seem to want to work at all.
I am running Access 2010, on Win 7 32 bit, (tried on 64 bit machine too).

Initially I was using Adobe reader as my default pdf viewer.

I typed the file location into the data control source for the web browser and initially on opening the form in Form View, it opened the pdf document fine, but in trying to close the form, go into design view, or changing the file location it seemed to have major issues with being able to close Adobe and view another file, and would take ages to close.

I decided to try another pdf viewer, and down loaded Foxit.

When opening in Form View it quickly opened the pdf in the web browser box, but then immediately showed a pop up error/information message box:

However, the box was totally blank with no message or text in it. If I clicked and moved the box the message then showed up:
“The command or action ‘’ isn’t available now.
You may be in a read-only database, or unconverted database…..”

If I closed this box, a second identical blank message box appeared (again if I moved it the same text appeared). And if I closed them both, the pdf file was correctly displayed. However, on trying to view a different pdf file, the same pop up yet again appeared twice.

From what I can find on the internet, the message “The command or action … isn’t available” would usually have some function name within the quote marks – however, my message had no name. I have not created any macros, or vba code at all, I just purely inserted the web browser in the form. I have tried creating a blank form in a new database, just putting a web browser in the form, and have got the same results. I don’t know what is generating this error message box.

In some of the original attempts, I did add the Foxit libraries in the References, and then on one attempt, forgot to do this, but still got the same pop up boxes.

I did also try the web browser control box with a word doc and excel spread sheet as the data control sources, and it opened up both Word and Excel fine – (asked if I wanted to open or save the file, but no other pop-up message boxes).

The web browser control seems to work OK now with Foxit, but I need to find a way to stop, or suppress these message boxes.

Any help or ideas would be very welcome, as I don’t really know what to try next.
Many thanks.
 

Ranman256

Well-known member
Local time
Yesterday, 20:58
Joined
Apr 9, 2015
Messages
4,337
dont view the pdf on the form, instead open the pdf in the pdf reader using the code below:

Paste this code into a module, and
it will open ANY file in its native application.

usage: OpenNativeApp ME.txtBox
if the file is myFile.pdf, will open it in acrobat
if the file is myFile.doc, it will open the doc in Word
if its just a file path, it will open in file explorer.
etc..

Code:
'Attribute VB_Name = "modNativeApp"
'Option Compare Database
Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1
Const SE_ERR_FNF = 2&
Const SE_ERR_PNF = 3&
Const SE_ERR_ACCESSDENIED = 5&
Const SE_ERR_OOM = 8&
Const SE_ERR_DLLNOTFOUND = 32&
Const SE_ERR_SHARE = 26&
Const SE_ERR_ASSOCINCOMPLETE = 27&
Const SE_ERR_DDETIMEOUT = 28&
Const SE_ERR_DDEFAIL = 29&
Const SE_ERR_DDEBUSY = 30&
Const SE_ERR_NOASSOC = 31&
Const ERROR_BAD_FORMAT = 11&


Public Sub OpenNativeApp(ByVal psDocName As String)
Dim r As Long, msg As String

r = StartDoc(psDocName)
If r <= 32 Then
    'There was an error
    Select Case r
        Case SE_ERR_FNF
            msg = "File not found"
        Case SE_ERR_PNF
            msg = "Path not found"
        Case SE_ERR_ACCESSDENIED
            msg = "Access denied"
        Case SE_ERR_OOM
            msg = "Out of memory"
        Case SE_ERR_DLLNOTFOUND
            msg = "DLL not found"
        Case SE_ERR_SHARE
            msg = "A sharing violation occurred"
        Case SE_ERR_ASSOCINCOMPLETE
            msg = "Incomplete or invalid file association"
        Case SE_ERR_DDETIMEOUT
            msg = "DDE Time out"
        Case SE_ERR_DDEFAIL
            msg = "DDE transaction failed"
        Case SE_ERR_DDEBUSY
            msg = "DDE busy"
        Case SE_ERR_NOASSOC
            msg = "No association for file extension"
        Case ERROR_BAD_FORMAT
            msg = "Invalid EXE file or error in EXE image"
        Case Else
            msg = "Unknown error"
    End Select
'    MsgBox msg
End If
End Sub


Private Function StartDoc(psDocName As String) As Long
Dim Scr_hDC As Long

Scr_hDC = GetDesktopWindow()
StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
End Function
 

HiTechCoach

Well-known member
Local time
Yesterday, 19:58
Joined
Mar 6, 2006
Messages
4,357
I don't know why you should not view a PDF of a form using the Web Browser control.

I have been using the native WBC to show all types of files including PDFs just fine in Access 2010 since it was first available.

It can be done with Adobe Acrobat Reader. There are some settings in Acrobat that you need to change. In Acrobat's options turn off opening in a separate window. If that does not work, let me know and I will figure out what eh other changes need to be.

FWIW: I have way to many issues with Acrobat Reader. I use and recommend the free Nitro PDF viewer (click here). Works great in the Access WBC.
 

laserfx

New member
Local time
Today, 01:58
Joined
Apr 1, 2011
Messages
4
Hi Ranman 256
Thanks, I might try that, but looks a bit advanced for my fairly basic VBA abilities. However, for my application, I did really want to show the pdf file within the access form. Many thanks,
LaserFX
 

laserfx

New member
Local time
Today, 01:58
Joined
Apr 1, 2011
Messages
4
Hi HiTechCoach
Many thanks for your reply - yes seems it could be some setting thing - I uninstalled Foxit and initially Adobe Reader opened in a new Adobe window, but after re-installing Abode it did open in the access form. I haven't looked at the settings so not sure if re-installing re-set something. I need to try the uninstall/ re-install on the computer at work to see what happens there. I will try Nitro, as my initial attempt with Adobe Reader was that it was slow opening, or rather closing the files.
I'm using the form with pdf viewer as a navigation sub-form, with each WBC data source taken from individual navigation buttons, so users could be wanting to change the pdf source file quite often - would work well, if the pdf viewer worked!!
- ps - seem to be having a problem at the moment downloading the Nitro viewer software!
Many thanks, LaserFX
 

laserfx

New member
Local time
Today, 01:58
Joined
Apr 1, 2011
Messages
4
Hi HiTechCoach

Fantastic - nearly there !! -
downloaded Nitro and it works brilliantly in the WBC on my form - however, it seems to default open the document as view full page and, I think, I want to open the documents as Full Width. I've tried a few settings in Nitro, (or maybe it's in the way the pdf has been created?) - is there an easy way to force the pdf in the WBC on the form to open Full Width?

ALSO, you mentioned that you use WBC for viewing all types of files - do Word / Excel files open up as a viewable document in the WBC, or do they always open up in a new window of the native application? I would also like to be able to view these files in the WBC on the form, but at present they ask "Do you wish to Open or Save file?" - and on opening, it opens up Word/Excel in a separate document. I think there may also be issues with .doc or .docx file extensions, but I guess maybe need a bit of code for that.

Many thanks,
LaserFX
 
Last edited:

HiTechCoach

Well-known member
Local time
Yesterday, 19:58
Joined
Mar 6, 2006
Messages
4,357
laserfx,

I view other file types that IE can display using the WBC. Like images or other files that you regularly see displayed on a web page.

The Word and Excel files with Office 2007 and later (.*x) files are actually a ZIP files. Not simple to show in a browser without additional software

The WBC is just a wrapper for Internet Explorer (IE). IE is for viewing web page content. It is just a bonus that it will also view a PDF within the document window of a browser/WBC.

If you must use the WBC then you will probably need to go through a web server with Document Management Software (DMS) that can display other file types. The DMS does all the work to make it viewable in a browser. That was it viewable in Access’s WBC.

You can purchase a custom control(s) that will probably do what you want with a Desktop app. Not tried any with Access.
 

Users who are viewing this thread

Top Bottom