Consulting

Results 1 to 3 of 3

Thread: VBA Print to PDF Button code issues with multiple users

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA Print to PDF Button code issues with multiple users

    Hello, I'm hoping somebody can help me with this, the code below allows users to print to pdf by clicking a button, but depending on the user, it may or may not work. I have concluded that the "NE" number is to blame, and that it's different between users. Can I alter the code to make it scan through "NE01" onwards, to make sure that this code works for everyone? I thought this code did that anyway, but appears as though it doesn't.

    Thanks in advance.
    Sub CommandButton2_Click()

    ActiveSheet.PageSetup.RightHeader = Format(Now, "MMMM DD, YYYY")

    PrtOK = True

    Dim Msg As String
    Dim C As Integer
    Dim PrinterName As String

    C = 1

    On Error GoTo MakePDFError:

    ResumePrinting:
    If C < 10 Then
    PrinterName = "Adobe PDF on Ne0" & C & ":"
    Else
    PrinterName = "Adobe PDF on Ne" & C & ":"
    End If

    Application.ActivePrinter = PrinterName
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
    "Adobe PDF on Ne04:", collate:=True

    Exit Sub

    MakePDFError:
    C = C + 1
    Resume ResumePrinting:
    End Sub


  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Have you tried the built-in pdf?

    Recorded macro
    Sub Macro7()
        ChDir "C:\Users\Emachine\Downloads"
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\Users\Emachine\Downloads\Daily List V2.pdf", Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
            True
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    As an alternative; (not so simple)
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=528
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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