Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good morning --
I want to print out a blank form (probably a pdf) from another application, then have the user reload that form into the printer and have Excel fill it out. I want to do it that way because it's a lot easier than designing the 10-page form in Excel, and it's a government form and I want them to accept it. So I'll have a MsgBox that says, "You're going to print out the right pdf form." Then I want the pdf form to print. It will be in the same directory as the Excel workbook. If the form is called "855B.pdf", can anyone help me with the command to print it out? Thanks in advance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 17, 11:21 am, pdberger
wrote: Good morning -- I want to print out a blank form (probably a pdf) from another application, then have the user reload that form into the printer and have Excel fill it out. I want to do it that way because it's a lot easier than designing the 10-page form in Excel, and it's a government form and I want them to accept it. So I'll have a MsgBox that says, "You're going to print out the right pdf form." Then I want the pdf form to print. It will be in the same directory as the Excel workbook. If the form is called "855B.pdf", can anyone help me with the command to print it out? Thanks in advance. Hello pdberger, This macro will print the PDF file you specify. By using the Windows API, you don't need to know which version of Acrobat Reader the user has or where it is on their system. After add ing a Standard VBA Module to your project, copy and paste the macro code into it. Example of calling the macro: PrintDoc "855B.pdf" If the file is not in the current directory you need to include the full directory path. 'Begin Macro Code 'Written: June 18, 2007 'Author: Leith Ross 'Summary: Print any document that is has a registered file extension Option Explicit Private Declare Function ShellExecute _ Lib "shell32.dll" _ Alias "ShellExecuteA" _ (ByVal hwnd As Long, _ ByVal lpszOp As String, _ ByVal lpszFile As String, _ ByVal lpszParams As String, _ ByVal lpszDir As String, _ ByVal FsShowCmd As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long ' Show Window Constants Const SW_HIDE = 0& Const SW_NORMAL = 1& Const SW_SHOWMINIMIZED = 2& Const SW_SHOWMAXIMIZED = 3& Const SW_SHOWNOACTIVATE = 4& Const SW_SHOW = 5& Const SW_MINIMIZE = 6& Const SW_SHOWMINNOACTIVE = 7& Const SW_SHOWNA = 8& Const SW_RESTORE = 9& Const SW_SHOWDEFAULT = 10& ' Error Code Constants Const SE_ERR_FNF = 2& Const SE_ERR_PNF = 3& Const SE_ERR_ACCESSDENIED = 5& Const SE_ERR_OOM = 8& Const SE_ERR_DLLNOTFOUND = 32& Const SE_ERR_SHARE = 26& Const SE_ERR_ASSOCINCOMPLETE = 27& Const SE_ERR_DDETIMEOUT = 28& Const SE_ERR_DDEFAIL = 29& Const SE_ERR_DDEBUSY = 30& Const SE_ERR_NOASSOC = 31& Const ERROR_BAD_FORMAT = 11& Public Sub PrintDoc(DocName As String) Dim hDesktop As Long Dim ShellRet As Long hDesktop = GetDesktopWindow() ShellRet = ShellExecute(hDesktop, "Print", DocName, "", "", SW_NORMAL) If ShellRet < 33 Then Call PrintError(ShellRet) End Sub Private Sub PrintError(ShellRet As Long) Dim Msg As String Select Case ShellRet Case SE_ERR_FNF Msg = "File not found" Case SE_ERR_PNF Msg = "Path not found" Case SE_ERR_ACCESSDENIED Msg = "Access denied" Case SE_ERR_OOM Msg = "Out of memory" Case SE_ERR_DLLNOTFOUND Msg = "DLL not found" Case SE_ERR_SHARE Msg = "A sharing violation occurred" Case SE_ERR_ASSOCINCOMPLETE Msg = "Incomplete or invalid file association" Case SE_ERR_DDETIMEOUT Msg = "DDE Time out" Case SE_ERR_DDEFAIL Msg = "DDE transaction failed" Case SE_ERR_DDEBUSY Msg = "DDE busy" Case SE_ERR_NOASSOC Msg = "No association for file extension" Case ERROR_BAD_FORMAT Msg = "Invalid EXE file or error in EXE image" Case Else Msg = "An unknown error occurred" End Select MsgBox Msg, vbCritical, "Print File" End Sub 'End Macro Code Sincerely, Leith Ross |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
New form of application.run | Excel Programming | |||
nice input application form | Charts and Charting in Excel | |||
Open Form (VBA Running) and Application.OnTime | Excel Programming | |||
Can I make an order form on an office application? | Excel Discussion (Misc queries) | |||
Display form from an VB application in Excel | Excel Discussion (Misc queries) |