Issues with macro not working anymore

jadams121

New Member
Joined
Jul 18, 2019
Messages
12
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

 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,332
.
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
 

Watch MrExcel Video

Forum statistics

Threads
1,101,956
Messages
5,483,890
Members
407,419
Latest member
Napoleao Paca

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top