Hi everyone. New to writing macros and having an issue. I wrote a macro that basically clicks on a dropdown to refresh report data, saves it as a PDF, clicks the ok box when complete and then moves to the next entry on the drop down list...and so on.

Problem comes with the last Sub I am running. For some reason, excel treats it as a separate macro, so it doesn't fire when I run. Here are the last 2 subs of my Macro. Let me know if you would like me to paste in the complete macro. Thanks.

Sub CreateAndSavePDF(PDFFileName As String, PDFContent As String)
Dim ws As Worksheet
Dim saveRange As Range

' Set the worksheet where you want to create the PDF from
Set ws = ThisWorkbook.Sheets("Sheet3") ' Replace with your actual sheet name

' Assuming you want to save the entire worksheet as a PDF
Set saveRange = ws.UsedRange

' Export the specified range as a PDF
On Error Resume Next
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
On Error GoTo 0

' Check if the PDF was successfully created
If Dir(PDFFileName) <> "" Then
MsgBox "PDF saved successfully as " & PDFFileName
Else
MsgBox "PDF creation failed."
End If

End Sub

Sub DismissPDFPrintNotification()
Dim startTime As Double
Dim timeoutInSeconds As Integer

' Set a timeout (in seconds) for waiting for the notification
timeoutInSeconds = 3 ' Adjust as needed

' Get the current time
startTime = Timer

Do
' Check if the Adobe Acrobat print dialog is open
Dim notificationWindow As LongPtr
notificationWindow = FindWindow("#32770", vbNullString) ' Find any window with class "#32770" (dialog)

If notificationWindow <> 0 Then
' Close the window by sending a WM_CLOSE message
SendMessage notificationWindow, &H10, 0, ByVal 0
Exit Do ' Exit the loop once the notification is closed
End If

' Exit the loop if the timeout has been reached
If Timer - startTime >= timeoutInSeconds Then Exit Do

' Allow other processes to run
DoEvents
Loop

End Sub