Open OLE Object

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi,

Two questions, and I feel bad asking one of them which should be easy...
1. Against all advice, I have a table with 1 field and 1 record, data type
of OLE, which contains a PDF. I want to create a command button on form,
with the Adobe image as the icon, to open this PDF. The ON CLICK opens the
table, reads that one record. How do I now open that PDF?

2. For purposes of updating that PDF with a newer version in the future, how
do I provide the user the ability to point to a PDF file and "import" a new
PDF into that one record/one field?

Thanks.
 
Hello David.

David said:
Two questions, and I feel bad asking one of them which should be
easy...
1. Against all advice, I have a table with 1 field and 1 record,
data type of OLE, which contains a PDF. I want to create a command
button on form, with the Adobe image as the icon, to open this PDF.
The ON CLICK opens the table, reads that one record.
How do I now open that PDF?

2. For purposes of updating that PDF with a newer version in the
future, how do I provide the user the ability to point to a PDF
file and "import" a new PDF into that one record/one field?

Some time ago I had the same task to solve, Here's what I ended
up with (Access 2003 with SQL 2005 backend):
I based the form on that table and added a bound object frame to the
form and bound it to the OLE field. I named that control objBlob.
It has to be visible, enabled and must not be locked. Since I did
not want to see it, I made it as small as possible and placed it
in the corner of an other control.
I added two buttons to the form: cmdAttach and cmdShow with the
following code:

---- BEGIN CODE ----

Private Sub cmdAttach_Click()
On Error GoTo ErrorTrap
' must have a reference to the Office object library

Dim strFilename As String

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.ButtonName = "Attach"
.Title = "Select file to attach..."
.Filters.Clear
.Filters.Add "Adobe PDF", "*.pdf"
If .Show = -1 Then
strFilename = .SelectedItems(1)
End If
End With

If strFilename <> "" Then
With Me.objBlob
If Not IsNull(.Value) Then .Value = Null 'delete first
.DisplayType = acOLEDisplayIcon
.OLETypeAllowed = acOLEEmbedded
.SourceDoc = strFilename
.Action = acOLECreateEmbed
End With
End If

ExitProc:
Exit Sub

ErrorTrap:
MsgBox Err.Description, vbExclamation
Resume ExitProc

End Sub

Private Sub cmdShow_Click()
On Error GoTo ErrorTrap

If Not IsNull(Me.objBlob) Then
Me.objBlob.Action = acOLEActivate
End If

ExitProc:
Exit Sub

ErrorTrap:
MsgBox Err.Description, vbExclamation
Resume ExitProc

End Sub

---- END CODE ----

I was quite satisfied with my soluiton. Yow about you?
 
Back
Top