Consulting

Results 1 to 9 of 9

Thread: Issue saving Excel Worksheet to .pdf

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Mar 2024
    Posts
    4
    Location

    Issue saving Excel Worksheet to .pdf

    I am working on adjusting an Excel file and am trying to get the save to .pdf to work and the macro runs with no errors but the save to .pdf is not working. Below is the VBA script

    Sub Printpdf()
    'Printpdf Macro
    ' Saves each sheet as a pdf
    'Keyboard Shortcut: Ctrl+w
    Set X = 6 for start of loop
        x = 6
        Do Until x = 250
    'Check for blank row in data sheet and stop looping
        Sheets("data sheet").Select
        Cells(x, 1).Select
        If Cells(x, 1) = 0 Then
        x = 250
        Else
        Sheets("scorecard").Select
    'Copy Supplier name from "data sheet" row "x" to "scorecard" sheet
        Sheets("data sheet").Select
        Cells(x, 1).Select
            Selection.Copy
            Sheets("scorecard").Select
            Range("E2").Select
            ActiveSheet.Paste
    ' Set variable s equal to supplier name in "scorecard" sheet
        s = Range("M5").Value
    ' Save the sheet as a pdf with the name "s"
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
             s, Quality:=xlQualityStandard, IncludeDocProperties _
             :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
             saveLocation = "C:\Users\kpost\Downloads"
    'Increment value of x for loop
        x = x + 1
        End If
        Loop
    End Sub
    Last edited by Aussiebear; 03-19-2024 at 03:53 AM. Reason: Added code tags to supplied code

Posting Permissions

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