Open or Save a PDF

T

Traci

I have a button that, when clicked, needs to prompt the user to save or open
the associated PDF. I have the open working fine with the following code:

Private Sub OpenUserGuide_Click()
Dim strDoc As String
strDoc = "\\Tx-filer01-aln\ise_projects\Knowledge_Base\BMG Knowledge Base
Reference Guide.doc"
Application.FollowHyperlink strDoc

End Sub

How do you get the code to prompt the user first to save or open?

Thanks!
Traci
 
F

freakazeud

Hi,
maybe you can clarify a little more.
You are talking about opening a pdf file, but your code references a word
document. Then you are talking about saving something...do you want to save a
new document (if, then what kind and where from) or do you want to save
something on a form in access, or do you want to make a copy of the document
you want them to open somewhere else before they open it?
Your message box can look something like this:

Select Case MsgBox("Want to save or not?", vbYesNo Or vbExclamation Or
vbDefaultButton1, Application.Name)
Case vbYes
'code to save whatever
Case vbNo
'code to open whatever or do nothing
End Select

HTH
Good luck
 
T

Traci

Sorry..I cut and paste the code before I changed the extension. I recently
converted the doc to PDF. When the user clicks the button, all I really need
is the following (pseudocode below):

If Button clicked
Pop dialog box asked user "Do you want to open the user guide or save it
to your local machine?"
If Save
Pop windows save box to all user to select location
Else
If Open
Open the document in Adobe reader
Else
Cancel

Does this make more sense?
 
F

freakazeud

Ok...so start with the code I gave you on the on click event of a button:

Select Case MsgBox("Want to save or not?", vbYesNo Or vbExclamation Or
vbDefaultButton1, Application.Name)
Case vbYes
'code to save whatever
Case vbNo
Application.FollowHyperlink "c:\path to the file\file.pdf"
End Select

Then on the vbYes case use code similar to this:
http://www.mvps.org/access/api/api0001.htm
To call the standard file save/open dialog...use the returned path with the
filecopy method to move the file to their local area from wherever...then
either execute the followhyperlink method as demonstrated in the vbNo case or
not depending on what you want.
HTH
Good luck
 
T

Traci

I have the following for the vbYes case, but I'm getting an error saying that
Sub or Function is not defined and the debugger highlights ahtAddFilterItem.
Sorry, I pretty new to VB.

Case vbYes
Dim strFilter As String
Dim strSaveFileName As String

strFilter = ahtAddFilterItem(myStrFilter, "Adobe PDF Files (*.pdf)",
"*.pdf")
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strFilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)

Case vbNo
Application.FollowHyperlink
"\\Tx-filer01-aln\ise_projects\Knowledge_Base\BMG Knowledge Base Reference
Guide.pdf"
 
F

freakazeud

Did you copy all the code on that site into a new module and save it?
The function you are calling will need that code.
Pay attention to the functino testit() in the code...you can use that code
as well.
This would still just open the open/save dialog...so you need to have
additional code to copy the file after this function returns a full path.
HTH
Good luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top