Number of Pages in Message Box

Doghouse

New Member
Joined
Mar 3, 2003
Messages
4
I want a message box to pop up and inform the user how many sheets of paper to load after printing.

The number of pages vary, so I need something based on &[Pages]

Here's what I have for my code:

WindowsName = MsgBox("Report has printed. Please load legal paper in printer.")

I need it to read "Report has printed. Please load 14 sheets of legal paper in printer." With 14 being the variable.

Is this possible?

Thanks in advance
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I would add one thing to that tip from J-Walk (The XLM one).

There's no need to activate the sheets, and you can even do the count on another workbook (Haven't tested if it works on a closed workbook yet)

<font face=Courier New>
<SPAN style="color:#00007F">Sub</SPAN> ShowPageCount()
    <SPAN style="color:#00007F">Dim</SPAN> PageCount <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, Sht <SPAN style="color:#00007F">As</SPAN> Worksheet, Pages <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> WB <SPAN style="color:#00007F">As</SPAN> Workbook
    <SPAN style="color:#00007F">Set</SPAN> WB = Workbooks("YourBook.xls")
    PageCount = 0
    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> Sht <SPAN style="color:#00007F">In</SPAN> WB.Worksheets
        <SPAN style="color:#007F00">'Sht.Activate</SPAN>
        Pages = ExecuteExcel4Macro("Get.Document(50, " & Chr(34) & "[" & WB.Name & "]" & Sht.Name & Chr(34) & ")")
        PageCount = PageCount + Pages
    <SPAN style="color:#00007F">Next</SPAN> Sht
    MsgBox "Total Pages = " & PageCount
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

</FONT>
 
Upvote 0

Forum statistics

Threads
1,221,695
Messages
6,161,360
Members
451,699
Latest member
sfairbro

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