PDF question

G

Gary

I have a command button that will open a particular PDF file.

Is there a way to have it open a file for that current record without having
to browse?

I am thinking I would name the file the same as the reference #, and then
possibly ask to open the file name that equals me.referenceno

Is this possible?
 
S

SusanV

Hi Gary,

Sure this is doable - so long as the filenames and path are consistent and
contain the reference number. I do a similar action opening Word documents:

Dim r As String
Dim file As String
Dim path As String
Dim doc As String

r = Forms!frmPMOReportData!txtRepNum
path = "\\LAN\PMQA\Reports\PMSheets\"
file = r & "PM.xls"
doc = path & file

Perhaps this will help,

SusanV
 
G

Gary

Got it.

I inserted:

Call Shell(doc, 1)

And it works great.

Thanks Susan.



SusanV said:
Hi Gary,

Sure this is doable - so long as the filenames and path are consistent and
contain the reference number. I do a similar action opening Word documents:

Dim r As String
Dim file As String
Dim path As String
Dim doc As String

r = Forms!frmPMOReportData!txtRepNum
path = "\\LAN\PMQA\Reports\PMSheets\"
file = r & "PM.xls"
doc = path & file

Perhaps this will help,

SusanV
 
S

SusanV

Hey Gary,

Glad to help - Sorry though - I didn't realize I had nipped the last line of
the code to actually open the doc!

;-)

Susan

Gary said:
Got it.

I inserted:

Call Shell(doc, 1)

And it works great.

Thanks Susan.
 
G

Gary

Susan,

What line do you use to actually call the file to open?

Do you have a Call Shell line, e.g.

Thanks.

Gary

SusanV said:
Hi Gary,

Sure this is doable - so long as the filenames and path are consistent and
contain the reference number. I do a similar action opening Word documents:

Dim r As String
Dim file As String
Dim path As String
Dim doc As String

r = Forms!frmPMOReportData!txtRepNum
path = "\\LAN\PMQA\Reports\PMSheets\"
file = r & "PM.xls"
doc = path & file

Perhaps this will help,

SusanV
 
S

SusanV

I use a custom function StartDoc, based on Shell execute, passing in the
variable "doc" from my previous post:

Function StartDoc(DocName As String)
On Error GoTo StartDoc_Error

StartDoc = ShellExecute(Application.hWndAccessApp, "Open", DocName, _
"", "C:\", SW_SHOWNORMAL)
Exit Function

StartDoc_Error:
MsgBox "Error: " & Err & " " & Error
Exit Function
End Function

Also, in the module's general declarations:

Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal Hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, ByVal nShowCmd _
As Long) As Long

Global Const SW_SHOWNORMAL = 1




--
hth,
SusanV





Gary said:
Susan,

What line do you use to actually call the file to open?

Do you have a Call Shell line, e.g.

Thanks.

Gary
 
G

Gary

Susan,

I'd like to do the same thing with a hypelink.

Can you tell me if this code would work?

Thanks.

Private Sub PODLinkButton_Click()
Dim url As String
Dim pro As String
Dim path As String

If Me.CarrierComboBox = SAIA Then
url = "http://www.saiasecure.com/tracing/manifest.asp?pro="
pro = Me.PRO_
path = url & pro
Application.FollowHyperlink (path)
End If
End Sub

SusanV said:
Hi Gary,

Sure this is doable - so long as the filenames and path are consistent and
contain the reference number. I do a similar action opening Word documents:

Dim r As String
Dim file As String
Dim path As String
Dim doc As String

r = Forms!frmPMOReportData!txtRepNum
path = "\\LAN\PMQA\Reports\PMSheets\"
file = r & "PM.xls"
doc = path & file

Perhaps this will help,

SusanV
 
S

SusanV

Sorry I haven't gotten back to you sooner, was out of the office. That ought
to work, assuming that PRO_ is a valid control name... Have you tried it?

Susan

Gary said:
Susan,

I'd like to do the same thing with a hypelink.

Can you tell me if this code would work?

Thanks.

Private Sub PODLinkButton_Click()
Dim url As String
Dim pro As String
Dim path As String

If Me.CarrierComboBox = SAIA Then
url = "http://www.saiasecure.com/tracing/manifest.asp?pro="
pro = Me.PRO_
path = url & pro
Application.FollowHyperlink (path)
End If
End Sub
 
G

Gary

I created this code by modifying the code you supplied for the PDF.

It does work.

Now I have to write an if statement to cover three different carrier websites.

I'll let you know how that goes.

Thanks again.

Gary
 
R

RodneyJay

Here's what I did to open a PDF..

On the "On Click" event of a button,

Dim r As String
Dim file As String
Dim path As String
Dim doc As String

r = Forms!WorkOrders!txtWorkOrderID
path = "C:\Program Files\Adobe\Reader 8.0\Reader\acrord32.exe c:\PDFFolder"
file = r & ".pdf"
doc = path & file

Call Shell (doc, 1)

In my job, I scan work orders and save them as the work order number. Then
if I need to view it once a client has signed it, I simply pull up the WO
number and click view which is the button where I placed the above code.

But I must thank Susan and Gary for their replies to one another as that's
where I got my idea.
 
Top