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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating PDF from VBA with sendkeys

Status
Not open for further replies.

MDJ52

MIS
Mar 30, 2001
120
US
I have code that will create an e-mail attachment to send an request for quote.
By using CutePDF I can also create this request as a PDF which is much more acceptable as attachments go.
My problem is the file name at create PDF time.
Is there a way to set the default so it will not even ask.
I have tried sendkeys and the timing is bad in the program, more than that once the popup comes up for the pdf writer, the program seems to lose focus so that it will not accept the sendkeys.
Any thoughts.
Thanks
 
change your pdf writer to some other like pdf4u

________________________________________________________
Zameer Abdulla
Help to find Missing people
All cats love fish but fear to wet their paws..
 
Help! I've been trying to do the same using CutePDF and I can't get it to work after days of trying. I can assign the printer to "PDF Writer" and that works great, but I can't get it to recognize the file location/name and bypass the "Save As" dialog box.

I'm new to setting registry values so it's likely my code is causing the problem. Any help is much appreciated.


Public Function RunPDF()

Dim lRetVal As Long
Dim hKey As Long
Dim sValue As String
Dim dbs As Object

'creates registry keys here which I can see in regedit
Dim Sh
Dim key
Set Sh = CreateObject("WScript.Shell")
key = "HKEY_CURRENT_USER\"
Sh.RegWrite key & "Software\CUSTPDF Writer\PDF Writer\", ""
Sh.RegWrite key & "Software\CUSTPDF Writer\PDF Writer\BypassSaveAs", "0", "REG_SZ"
Sh.RegWrite key & "Software\CUSTPDF Writer\PDF Writer\OutputFile", "0", "REG_SZ"
Sh.RegWrite key & "Software\CUSTPDF Writer\PDF Writer\StartAt", "0", "REG_DWORD"


Set dbs = Application.CurrentProject

'The code below came with the software but I can't get it to modify the registry keys that I have created

lRetVal = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\CUSTPDF Writer\PDF Writer", 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hKey, lRetVal)

sValue = "C:\Sample.pdf"

RegSetValueEx hKey, "OutputFile", 0&, REG_SZ, sValue, Len(sValue)

sValue = "1"
RegSetValueEx hKey, "BypassSaveAs", 0&, REG_SZ, sValue, Len(sValue)


' To set the default printer (this works successfully using a separate function)
SetDefaultPrinter ("PDF Writer")

Dim AccessDoc As Access.Report
Set AccessDoc = Reports![Report1]
'the report is already open so no need to open it
DoCmd.PrintOut
DoCmd.Close

sValue = "0"
RegSetValueEx hKey, "BypassSaveAs", 0&, REG_SZ, sValue, Len(sValue)
RegCloseKey (hKey)

End Function
 
Of course, as usual when I post something, I figured it out a short time later. I was putting the registry keys in the wrong spot. Thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top