Hello,
I found allot of ways to do this online, but not quite what Im looking for....I have a userform with a save as pdf button....Ideally when the user clicks the button, Id like it to automatically save as a pdf and also Id like it to print portrait as well....I was using this code:
but it didn't something a little different than what I want:
http://www.mrexcel.com/forum/excel-q...me-path-2.html
Here is my currect code for the save as pdf button........Has anyone ever done this before, and have any insight as to how to do it:
Regular Module:
Private Const HWND_BROADCAST As Long = &HFFFF&
Private Const WM_WININICHANGE As Long = &H1A
Private Declare Function SendNotifyMessage Lib "user32" Alias "SendNotifyMessageA" ( _
ByVal hwnd As Long, _
ByVal msg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" ( _
ByVal pszPrinter As String) As Long
Public Sub ChangePrinter(NewPrinter As String)
SetDefaultPrinter NewPrinter
Call SendNotifyMessage(HWND_BROADCAST, _
WM_WININICHANGE, _
0, ByVal "windows")
End Sub
In the Command button on the userform:
Private Sub CommandButton3_Click()
Dim OldPrinter As String
Dim NewPrinter As String
OldPrinter = Left(Application.ActivePrinter, InStrRev(Application.ActivePrinter, "on ") - 2)
Application.Dialogs(xlDialogPrinterSetup).Show
NewPrinter = Left(Application.ActivePrinter, InStrRev(Application.ActivePrinter, "on ") - 2)
ChangePrinter NewPrinter
Me.PrintForm
ChangePrinter OldPrinter
End Sub
Bookmarks