![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 3
|
Hi,
I'd like to know if there's a way (using VBA) to get the total number of pages of a sheet? I've tried difference variations of this code: HorizBreaks = Worksheets(1).HPageBreaks.Count HPages = HorizBreaks + 1 VertBreaks = Worksheets(1).VPageBreaks.Count VPages = VertBreaks + 1 NumPages = HPages * VPages and it still doesn't work. Any help you can give me would be greatly appreciated. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi Robert,
PageCount = ExecuteExcel4Macro("Get.Document(50)") For more detail, follow the responses in this link. http://mrexcel.com/board/viewtopic.p...c=5067&forum=2 Bye, Jay |
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Posts: 3
|
WOW.....really fast service....like 5 minutes fast......Thanks a million Jay...the code works awesome!
|
|
|
|
|
|
#4 |
|
New Member
Join Date: May 2002
Posts: 3
|
Jay,
I'm using this in Access and I am making a connection to excel like this: Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet 'Setup Excel Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Add Set xlSheet = xlBook.Worksheets(1) but when I try your code (which I think is right): intPageCount = xlApp.ExecuteExcel4Macro("Get.Document(50)") it returns 1.....any clue? |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|