Opening Print Dialog Box and Printing to Microsoft PDF successfully

jkinnick

New Member
Joined
Aug 31, 2016
Messages
12
Hi, I am having some trouble with what should simple VBA code that is producing an error and locking up Excel when I run the macro to where I have to go to my Task Manager to force-close Excel.

I am trying to have the macro select the 'Cover' tab in my workbook, then open the Print Dialog Box. It does this but when I click Print, it returns the error messages shown below. Does anyone know how to fix this or write the VBA code in a different way to produce the result I want without errors?

My VBA Code for the Macro:
Sub Print_Cover()
'
Sheets("Cover").Select
Application.Dialogs(xlDialogPrint).Show

End Sub

I run the Macro and get the print dialog box like I want:

1602795492822.png

I hit OK ,and I get this error message:
1602795533730.png

After I hit OK on this error message I get this error message from the Anaplan add-in I have to use that creates a live connection to our data in Anaplan. (Could have something do with it, but the macro worked perfectly before their latest update)
1602795610130.png

Screenshot of VBA Code:
1602795629730.png
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,223,939
Messages
6,175,533
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top