Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Current PDF from VB with a new name from fields on the form

Status
Not open for further replies.
Jan 28, 2004
19
US
I am new to VB and I am trying to use the code below to open selected PDF and Word Files.

My code allow me to open the required files but I am having a hard time saving the PDF file from VB. MY hope is to save current open document with a new name.

For example, if the file opened was called test.pdf my goal is to save it as testnew.pdf when the save button is clicked on the ACCESS FORM.

Here is the code I have so far...

Private Sub Combo4_AfterUpdate()
Dim template As String, WORD_EXE As String, PDF_EXE As String

WORD_EXE = "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE "
PDF_EXE = "c:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe "
Dim loc As String
Dim filesel As String
loc = "c:\Corrections_CFW\Test\"
filesel = Combo4

If Combo4 = "Audit.doc" Then
'MsgBox ("audit selected")
'template = "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE " & loc & filesel
template = WORD_EXE & loc & filesel

Call Shell(template, 1)
Combo4 = "Select Form to Sign"
'Exit_Combo4_Click:
Exit Sub
Else
template = PDF_EXE & loc & filesel
'template = "c:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe " & loc & filesel

Call Shell(template, 1)
Combo4 = "Select Form to Sign"
Exit_Combo4_Click:
Exit Sub
End If
End Sub
 
Just use file system objects. Make sure that you add Microsoft Scripting Runtime to your references.

Code:
Dim fso As FileSystemObject
...
fso.CopyFile oldpathname, newpathname

Depending on the type of objects, you may or may not be able to do this while the oldpathname is open.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top