Link to home
Start Free TrialLog in
Avatar of wardn
wardn

asked on

ole server error when opening adobe documents

I created a table that has a ole object field labeled PDF to store Adobe documents.

I have a form that has that ole object on it.  I have the settings set for embedded object so the document would be stored in the MDB and not somewhere else in a folder where it could accedintally be deleted.  When I click on the ole object frame to add it, I don't have any problems getting the pdf document.  It is when I open the document in a Adobe 7.0 reader.

When I double click on the ole object frame the auto activate does its thing and openes the document in the acrobat reader, but when I close the acrobat reader I get an ole server error.

'The operation on the Acrobat Document object failed.

' The OLE server may not be registerd.'
' To register the OLE server, reinstall it.'
'----------
'|   OK   |
'-----------

I then tried the same thing with a computer that has adobe pro, which allows writing adobe documents, and I don't have the problem.

I even tried leaving the adobe reader open prior to double clicking, auto activate, the pdf ole object and still get the error when I close that particular document.

Is there a way to control acrobat so I don't get this error in an adobe reader vise an adobe writer.

I have adobe as a reference, but I don't unstand the codes that control it.

I just want to beable to click on a button that does two things.
1) if ole object is null, get object from file.
2) if ole object is not null, then open pdf in read only mode, once adobe is closed return focus back to ms access.
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

wardn,

' The OLE server may not be registerd.'
' To register the OLE server, reinstall it.'

OK... so then did you try Re-installing Adobe?

Jeffc
Avatar of wardn
wardn

ASKER

I tried that and I still get the error.
<I have adobe as a reference, but I don't unstand the codes that control it.>

What code do you have? If you use the reference, then all machines to which you will distribute this will need to have the same reference ... I'm not sure how much of Adobe is redistributable, so can't help you there ... this would seem like a problem with code attempting to run methods not available in the Reader, or with code that cannot find the referenced object.

Further, it's considered bad design to store OLE objects in an Access database. They are very prone to corruption, and will bloat the database tremendously. Most experienced devs prefer to simply store links to the objects instead of the object itself. Of course this doesn't make the db easily portable, but there are methods to handle that as well.

Avatar of wardn

ASKER

I would prefer to use the link method, but to do so I don't know how to grab the original location, copy and paste it into a new location with a new name so there are no identical file names.  The database stores training documents of each employee, and each one can e-mail the pdf document to the training office, but if they have the same same then they can't link it or paste it.
To prevent corruption of the file, is there a way to have the program rename the file, grab that file and place it into another location for linking purposes?  And if so, how do I get a series of linked files to print on one command, like a report? So the print out would be like a training folder would be when it is printed out of all the pdf documents.  When it prints the linked file it just does not print just one pdf, but a series of pdfs in the correct order as it would be stored in the db?  
The folder that the pdf or doc file would be stored is a hidden folder so know one, but the program itself accesses it, to prevent accidental deleting of files.
Avatar of wardn

ASKER

I appriciate all the advice, but I did some research and code looking and found a solution to my question.  It started out embedding the pdf, but now it is a linked file in a new location.  This deicision was based on the info that it is bad to store pdf or doc files inside a mdb.  The way I did this was by using an api function from "comdlg32.dll"
first I build a module for browsing folders with the api function GetOpenFileNameA using code from http://www.dbforums.com/printthread.php?t=543737

in the module I added a public string variable labeled ext for "extention" for relocating the file purposes

I then created a new function to grab the extion of the file.
' error code removed to save space in this comment block
' Trim ending from a string returned by an API call.
Private Function tsTrimExt(ByVal strItem As String) As String
    Dim i As Integer
    i = Len(strItem) - InStrRev(strItem, ".")
    If i > 0 Then
        tsTrimExt = Right(strItem, i + 1)
    Else
        tsTrimExt = strItem
    End If
End Function

where in the original browse file module I placed
ext = tsTrimExt(tsTrimNull(tsFn.strFileTitle))
this allowed me to get only the original extention of the file.

on the command button which from the web site I mentioned to open the file I added additional code to copy the file from its original location, using the tsGetFileFromUser call declared in the module.

Dim newfilename As String 'declare a new file name string
'create new file name from field on form and the ext created in the module.  So if the file was a pdf the new file name would also have the extension pdf.
newfilename = Doc_Name & ext
newfilename = "h:\SIMPDATA\" & newfilename 'finish recreating new file location with new file name
FileCopy varFileName, newfilename ' copy the original file located at varFileName and relocated it to newfilename's location with new name.

I just changed the field's value from being the varfilename after locating the file wanted to the new file's location and name.

I then used the name field for the document to open the link address provided in the link field upon double clicking on the name using the code:
Dim ctl As CommandButton
    Set ctl = Me!Command4 'a command button that is invisible to the user.
    With ctl
        .Visible = False
        .HyperlinkAddress = List1 'list1 is a txtBox with the value of the link
        .Hyperlink.Follow
    End With

If any one would like all the code placed into the box please reply and I will place both the module and form code with table design.
ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial