Preview a .dwg or .pdf file within a form

mrcateriv

New member
Local time
Today, 09:04
Joined
Dec 16, 2012
Messages
4
Currently, I've given my users the ability to select the file that they are referencing as an attachment through the file dialog option. What I would now like to do is generate a preview of that file within a box in the form. I have this working for jpeg but I'm having trouble with .tif, .pdf, and .dwg files. For .pdf files, the control box that it appears in just turns gray from initially having the PDF icon in it. For tif files, no image appears and the same for dwg files. Any help would be greatly appreciated. Here is my current code:

Private Sub ImagePath_AfterUpdate()
' After selecting an image for the employee, display it.
On Error Resume Next
showErrorMessage
showImageFrame
If (Me!ImagePath) = True Then
Me![ImageFrame].Picture = path & Me![ImagePath]
Else
Me![ImageFrame].Picture = Me![ImagePath]
End If
End Sub

Private Sub cmdAddPicture_Click()
' Use the Office File Open dialog to get a file name to use.
getFileName
End Sub

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current document. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Relative Image"
.Filters.Add "JPEGs", "*.jpg; *.pdf"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = "F:\" & Me.txtFirst & "\" & Me.txtSecond
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me!Command117.SetFocus

End If
End With

End Sub

Private Sub Form_Current()
' Display the picture for the current work order if the image
' exists. If the file name no longer exists or the file name was blank
' for the current record, set the errormsg label caption to the
' appropriate message.
Dim res As Boolean
Dim fName As String

path = CurrentProject.path
On Error Resume Next
errormsg.Visible = False
If Not IsNull(Me!Photo) Then
res = (Me!Photo)
fName = Me![ImagePath]
If (res = True) Then
fName = path & "\" & fName
End If

Me![ImageFrame].Picture = fName
showImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette
If (Me![ImageFrame].Picture <> fName) Then
hideImageFrame
errormsg.Caption = "Picture not found! Please make sure that the pictures was saved to K:\Shared\M & W\M & W\Work Order Pictures"
errormsg.Visible = True
End If
Else
hideImageFrame
errormsg.Caption = "Click Add/Edit to add picture"
errormsg.Visible = True
End If


I look forward to any help on this. Thanks
 

Users who are viewing this thread

Back
Top Bottom