Issues with macro not working anymore
Results 1 to 2 of 2

Thread: Issues with macro not working anymore
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Issues with macro not working anymore

    Good afternoon,

    I'm new to VB and I found this code, which worked for me perfectly fineyesterday, but now it just stopped doing anything. Does anyone know why itstopped, or is there something obvious I need to consider when trying totroubleshoot it? file path I correct, as are the cell locations referenced

    Thank you in advance.


    '-------------------------------------------------------------------------------
    Sub Save_as_Pdfs()
    '-------------------------------------------------------------------------------
    ' Saves marked sheets as PDF file.

    Const PDF_path = "D:\PDF"

    Dim Snr As Integer
    Dim Name As String

    'Process all sheets in workbook
    For Snr = 1 To ActiveWorkbook.Sheets.Count
    Sheets(Snr).Activate
    'Only print if c4 contains "NOTE"
    If Cells(4, "C").Value = "NOTE" Then
    Name = PDF_path & ActiveSheet.Name & Cells(4, "B").Value & ".pdf"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Name, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, OpenAfterPublish:=False
    End If
    Next Snr
    End Sub


  2. #2
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,675
    Post Thanks / Like
    Mentioned
    34 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Issues with macro not working anymore

    .
    This works here :

    Code:
    Option Explicit
    
    
    '-------------------------------------------------------------------------------
    Sub Save_as_Pdfs()
    '-------------------------------------------------------------------------------
    ' Saves marked sheets as PDF file.
    Dim PDF_path As String
    Dim Snr As Integer
    Dim Name As String
    
    
    PDF_path = "C:\Users\My\Desktop\PDF\"   'edit path as required
    
    
    On Error Resume Next
    
    
    'Process all sheets in workbook
    For Snr = 1 To ActiveWorkbook.Sheets.Count
        Sheets(Snr).Activate
        'Only print if c4 contains "NOTE"
        If Cells(4, "C").Value = "NOTE" Then
            Name = PDF_path & ActiveSheet.Name & Cells(4, "B").Value & ".pdf"
            ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Name, _
            Quality:=xlQualityStandard, IncludeDocProperties:=False, _
            IgnorePrintAreas:=False, OpenAfterPublish:=False
        End If
    Next Snr
    End Sub

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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