|
Question : How can I display a .pdf on my access form?
|
|
I have designed a couple of databases, but they are somewhat simple, and Im just moving up to something more complex: When I was working with .tiff images, this code worked fine to get them to display on my form. Now that we have converted all of our images to .pdf format, obviously it wont work any more. What exactly do I need to do to make this work for .pdf files?
Private Sub Form_Current() Dim ImagePath As String Me![ImagePath].Value = "C:\General Recording\BOOK " Me![ImagePath].Value = Me![ImagePath].Value + [txtBook] Me![ImagePath].Value = Me![ImagePath].Value + "\B" Me![ImagePath].Value = Me![ImagePath].Value + [txtBook] Me![ImagePath].Value = Me![ImagePath].Value + "P" Me![ImagePath].Value = Me![ImagePath].Value + [txtPage] Me![ImagePath].Value = Me![ImagePath].Value + ".pdf" frmImageBox![PictureImage].Picture = Me![ImagePath] End Sub
Does the ImageBox need to be an activex control? The only differences between the above code and the code I actually used before is that the path is a little different, and of course the file suffix at the end was .tif instead of .pdf.
Does this path ultimately have to end up in the src field for the adobe activex object? And can I do this with the above code-generated variable? When I go to my toolbox, I can find the adobe acrobat control for active x, but when I go to tools>ActiveX Controls>etc. and try to register this adobe acrobat control for activex, it wants me to navigate to the location of the file. My version 7 folder for acrobat doesnt seem to have the necessary file, but the version 5 folder has an item called pdf.ocx in the activex folder. Is this what I want, and is this the way I want to use it?
Also, just before I post this, it looks like my last line of code will have to incorporate the name of whichever control object is going to display the .pdf. Not sure what the syntax for that will be.
|
|
Answer : How can I display a .pdf on my access form?
|
|
The WebBrowser is an ActiveX control, and as such Access doesn't support Intellisense (which is what provides you with the Properties and Methods of an Object). To see those items:
Dim obj As WebBrowser Set obj = Me.ActiveXctl.Object
Of course, you'd have to rename the ActiveXCtl to match the name in your project.
Try this code in the CurrentEvent of your FORM:
Sub Form_Current()
Dim obj As WEbBrowser Dim strPath as STring
Set obj = Me.NameOfYourBrowserControl.Object strpath = "C:\General REcording\BOOK" & Me!txtBook & "\B" & Me.txtBook & "P" & Me.txtPage & ".pdf"
'/preview the path, to make sure it's correct msgbox strPath
obj.Navigate strpath
End Sub
|
|
|
|