+ Reply to Thread
Results 1 to 7 of 7

Print a PDF document from Userform Command Button

  1. #1
    Registered User
    Join Date
    09-10-2009
    Location
    Brighton,England
    MS-Off Ver
    Excel 2003
    Posts
    44

    Print a PDF document from Userform Command Button

    HI,

    I have a userform from which I need to be able to print a PDF document when the command button is pressed.

    User enters the document number in docnum textbox (eg. 123)

    On pressing the commandbutton printdoc, I need to be able to print document 123.PDF to default printer

    All PDF Documents reside in a network folder mapped to the S:\PDF\drive.

    If the document is not found I need to display an error message stating this and return focus back to the textbox.

    If the document is found I need to display a message stating document sent to printer.

    Is this possible?

    Any help appreciated
    Attached Files Attached Files
    Last edited by msommerf; 10-20-2009 at 11:29 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Print a PDF document from Userform Command Button

    Your UserForm does not have a Commandbutton.

    It would be beter to have a combobox list the avilable files then the combobox change event could print the selected file
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-10-2009
    Location
    Brighton,England
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Print a PDF document from Userform Command Button

    I have managed to get ShellExecute to work as a macro in a spreadsheet to be able to print a PDF document.

    Can anyone tell me how I go about assigning this to a command button in a userform?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Print a PDF document from Userform Command Button

    What code do you have? You just place it in the Commandbutton_Click event, double click on the butto in the VB Editor

  5. #5
    Registered User
    Join Date
    09-10-2009
    Location
    Brighton,England
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: Print a PDF document from Userform Command Button

    OKay - I have that solved now. I didn't have the module loaded

    I have one more question please:

    I am using shell execute to print a PDF file. The PDF filename changes based on the value of a text box. For example:

    User types 123 in a text box

    On clicking the command button, shellexecute runs and opens file c:\MOT\123.PDF
    How do I code the filename using the input from the text box?

    Please Login or Register  to view this content.
    [/COLOR]Any help appreciated
    Last edited by royUK; 10-20-2009 at 12:38 PM. Reason: Did not comply with rule3 Sorry

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Print a PDF document from Userform Command Button

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Print a PDF document from Userform Command Button

    Where's the textbox & hat type have you used?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1