Access passing to a shell command prompt

Dear Experts

I am trying to run a windows 7 shell command from Access to merge 2 pdfs (courtesy of pdftk) and this is the end result I need to achieve in the command prompt

C:\Users\xxx>pdftk "C:\Users\xxx\Desktop\MSPowerPoints\Doc1.
pdf" "C:\Users\xxx\Desktop\MSPowerPoints\Doc2.pdf" cat output "C:\User
s\xxx\Desktop\MSPowerPoints\output1.pdf"

The command definitely works when pasted directly into the “command box”

The code I am using is this …
Option Compare Database
Option Explicit


Private Sub Toggle2_Click()
Dim Hello As String
Dim Doc1 As String
Dim Doc2 As String
Dim Doc3 As String
Doc1 = "''C:\Users\xxx\Desktop\MSPowerPoints\Doc1.pdf''"
Doc2 = "''C:\Users\xxx\Desktop\MSPowerPoints\Doc2.pdf''"
Doc3 = "''C:\Users\xxx\Desktop\MSPowerPoints\output1.pdf''"
Hello = "pdftk " & Doc1 & " " & Doc2 & " cat output " & Doc3
MsgBox Hello
Call Shell("cmd.exe" & Hello, vbNormalFocus)
End Sub

Open in new window


But I keep getting “run time error 53 – file not found” I have put in a message box in the code so I can see the command and it all looks good

Any ideas, can anyone help?
correlateAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewCommented:
Give this a try:

Option Compare Database
Option Explicit

Private Sub Toggle2_Click()
Dim Hello As String
Dim Doc1 As String
Dim Doc2 As String
Dim Doc3 As String
Doc1 = """C:\Users\xxx\Desktop\MSPowerPoints\Doc1.pdf"""
Doc2 = """C:\Users\xxx\Desktop\MSPowerPoints\Doc2.pdf"""
Doc3 = """C:\Users\xxx\Desktop\MSPowerPoints\output1.pdf"""
Hello = "pdftk " & Doc1 & " " & Doc2 & " cat output " & Doc3
MsgBox Hello
Call Shell("cmd.exe" & Hello, vbNormalFocus)
End Sub

Open in new window

~bp
0
correlateAuthor Commented:
Hi,

Thanks for that, alas I still have the same error,
0
Bill PrewCommented:
Okay, where is the pdftk.exe file located, if the folder it is in in the PATH environment variable?

Have you tried fully qualifying the path to that executable, like:

Hello = """c:\utils\pdftk\pdftk.exe"" " & Doc1 & " " & Doc2 & " cat output " & Doc3

Open in new window

Sorry this isn't more specific but I don't own or use pdftk myself, just trying to look for generic problems that could be occuring.

~bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
correlateAuthor Commented:
Perfect, that nailed it - thank you very much for your help with this one
0
Bill PrewCommented:
Welcome, glad that helped.

~bp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.