+ Reply to Thread
Results 1 to 2 of 2

Printing and Saving of a Userform code

  1. #1
    Forum Contributor
    Join Date
    10-30-2014
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    111

    Printing and Saving of a Userform code

    Morning,
    I was hoping that somebody can help me adapt the following code where a userform is being printed.
    My problem is it works fine, choosing a printer etc. The problem is that I do not want this code to change the users default printer automatically to the preferred printer for this specific printing job. Example, my computers default printer is an HP Laserjet always, but when I click to print the userform I choose let’s say print to pdf. It does this perfectly, but later I want to print some other random document then my default printer on my comptures has changed to the pdf printer. I want to prevent this when choosing a printer for the userform. I hope I am making sense.

    Please Login or Register  to view this content.
    Private Sub CommandButton3_Click()

    Dim fileOK As Boolean
    Dim sPrinter As String

    With Application
    sPrinter = .ActivePrinter
    fileOK = .Dialogs(xlDialogPrinterSetup).Show
    End With

    If fileOK = True Then
    ChangeDefaultPrinter (Application.ActivePrinter)
    Project_Dashboard.PrintForm
    ChangeDefaultPrinter (sPrinter)

    End If

    End Sub


    Public Sub ChangeDefaultPrinter(pName As String)

    Set oWord = CreateObject("Word.Application")
    oWord.WordBasic.FilePrintSetup Printer:=pName, DoNotSetAsSysDefault:=0
    Set oWord = Nothing

    End Sub
    Please Login or Register  to view this content.
    Another question: If I want to build in a commandbutton to save the userform to file as an image, how I would do this in vba code so I can select the file location, change the file name etc. That normal “save as” pop-up box.

    Thank you in advance!!!!

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Printing and Saving of a Userform code

    For selecting where to Save, you need FileDialog

    http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx
    If someone has helped you then please add to their Reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Printing and Saving of a Userform code
    By Raylou in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2014, 04:22 AM
  2. Need to restrict Saving & Printing a spreadsheet
    By shaung411 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2014, 01:33 PM
  3. Saving/Printing Multiple Charts into 1 PDF
    By ditee26 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 07-16-2013, 12:09 PM
  4. Code to prevent userform from saving duplicates based on 3 textboxes
    By Zygoid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2013, 11:04 AM
  5. vba code: password-required printing and saving
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2013, 09:40 AM

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