ExecuteExcel4Macro("GET.DOCUMENT(50)")

  • Thread starter Thread starter Shawn777
  • Start date Start date
S

Shawn777

ExecuteExcel4Macro("GET.DOCUMENT(50)")

Is suppose to provide the number of pages to be printed. I have the
following code that reprecents two pages to print it the above code says it
is just one.

Sub PrintDirect()

Sheets("DIRECT").Select

Application.Run "'RCA_RB3 06-122-S2 all crafts_rev 2 WBU
macros.xls'!Enlarge"
Application.Run "'RCA_RB3 06-122-S2 all crafts_rev 2 WBU
macros.xls'!ReduceDir"
ActiveSheet.ResetAllPageBreaks
ActiveSheet.PageSetup.PrintArea = "$B$1:$N$199"
With ActiveSheet.PageSetup
.CenterHorizontally = True
.Orientation = xlLandscape
.FitToPagesWide = 1
End With
Range("H1").Select

' MsgBox ExecuteExcel4Macro("GET.DOCUMENT(50)") & " pages will be printed."

If ExecuteExcel4Macro("GET.DOCUMENT(50)") = 1 Then
Application.Run "PrintPage"
Else
Rows("59:59").Select
Range("B59").Activate
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Application.Run "PrintPage"
End If

End Sub

This worked for me before and now it doesn't. Anyone know why?
 
It doesn't seem to work correctly with Zoom property set to false.
That's as much as I can figure out. I have a one-page document with
your fit settings, and the expression returns two. If I set Zoom to
100, it returns 4 which is correct. That seems to make the
difference.
 
Changing the Zoom didn't change anything for me.

Is there another way of counting the number of pages that are to be printed?
 
That xl4 function has a second argument which takes the sheet name...

ExecuteExcel4Macro("GET.DOCUMENT(50, sheetname)")

Try running it that way with a "normal" sheet active.
Include the workbook name along with the sheet name.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Shawn777"
wrote in message
ExecuteExcel4Macro("GET.DOCUMENT(50)")
Is suppose to provide the number of pages to be printed. I have the
following code that reprecents two pages to print it the above code says it
is just one.
-snip-
This worked for me before and now it doesn't. Anyone know why?
 
I tried typing in the tab name and the spreadsheet name, neither would work

The spreadsheet name is: rb3 wbu macro.xls
The tab name is: DIRECT
The path is: C:\Documents and
Settings\fogas2\Desktop\Shawn\Clients\OCC\Ring Bus 3 Val\IPA\rb3 wbu macro.xls

Could you type it in correctly so I can make sure I did it right?
 
Here is the syntax I use...
(that still doesn't mean the count will be correct) <g>
'---
Sub LotsOfStrings()
Dim strWB As String
Dim strName As String
Dim strFiller As String
Dim lngCount As Long

strWB = "[" & ActiveWorkbook.Name & "]"
strName = Worksheets(23).Name
strFiller = "get.document(50,""" & strWB & strName & """)"
lngCount = ExecuteExcel4Macro(strFiller)
MsgBox lngCount
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Shawn777"
wrote in message
I tried typing in the tab name and the spreadsheet name, neither would work

The spreadsheet name is: rb3 wbu macro.xls
The tab name is: DIRECT
The path is: C:\Documents and
Settings\fogas2\Desktop\Shawn\Clients\OCC\Ring Bus 3 Val\IPA\rb3 wbu macro.xls
Could you type it in correctly so I can make sure I did it right?
-snip-
 
If you actually print the sheet, how many pages are printed?
Jim Cone



"Shawn777"
wrote in message
No, it didn't work. It just returns 4 pages each time.
 
2 pages are printed - the number it is suppose to be, not the number the
marco says it is. Your's says its 4 pages mine says its 1 page.

My code is below, I deactivated everything that doesn't work right.

Sub PrintAreaDirect()

'Dim strWB As String
'Dim strName As String
'Dim strFiller As String
'Dim lngCount As Long

'strWB = "[" & ActiveWorkbook.Name & "]"
'strName = Worksheets(23).Name
'strFiller = "get.document(50,""" & strWB & strName & """)"
'lngCount = Application.ExecuteExcel4Macro(strFiller)

Sheets("DIRECT").Select

Application.Run "'RCA_RB3 06-122-S2 all crafts_rev 2 WBU
macros.xls'!Enlarge"
Application.Run "'RCA_RB3 06-122-S2 all crafts_rev 2 WBU
macros.xls'!ReduceDir"
ActiveSheet.ResetAllPageBreaks
ActiveSheet.PageSetup.PrintArea = "$B$1:$N$199"
With ActiveSheet.PageSetup
.CenterHorizontally = True
.Orientation = xlLandscape
.FitToPagesWide = 1
End With
Range("H1").Select

MsgBox Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") & " pages will
be printed."

' If ExecuteExcel4Macro("GET.DOCUMENT(50)") <> 1 Then
Rows("59:59").Select
Range("B59").Activate
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Application.Run "PrintPage"
' Else
' Application.Run "PrintPage"
' End If

End Sub

Jim Cone said:
If you actually print the sheet, how many pages are printed?
Jim Cone



"Shawn777"
wrote in message
No, it didn't work. It just returns 4 pages each time.




Jim Cone said:
Here is the syntax I use...
(that still doesn't mean the count will be correct) <g>
'---
Sub LotsOfStrings()
Dim strWB As String
Dim strName As String
Dim strFiller As String
Dim lngCount As Long

strWB = "[" & ActiveWorkbook.Name & "]"
strName = Worksheets(23).Name
strFiller = "get.document(50,""" & strWB & strName & """)"
lngCount = ExecuteExcel4Macro(strFiller)
MsgBox lngCount
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
 
Hi Shawn

Difficult to see the problem from here.
Do you have the problem also with more workbooks ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Shawn777 said:
2 pages are printed - the number it is suppose to be, not the number the
marco says it is. Your's says its 4 pages mine says its 1 page.

My code is below, I deactivated everything that doesn't work right.

Sub PrintAreaDirect()

'Dim strWB As String
'Dim strName As String
'Dim strFiller As String
'Dim lngCount As Long

'strWB = "[" & ActiveWorkbook.Name & "]"
'strName = Worksheets(23).Name
'strFiller = "get.document(50,""" & strWB & strName & """)"
'lngCount = Application.ExecuteExcel4Macro(strFiller)

Sheets("DIRECT").Select

Application.Run "'RCA_RB3 06-122-S2 all crafts_rev 2 WBU
macros.xls'!Enlarge"
Application.Run "'RCA_RB3 06-122-S2 all crafts_rev 2 WBU
macros.xls'!ReduceDir"
ActiveSheet.ResetAllPageBreaks
ActiveSheet.PageSetup.PrintArea = "$B$1:$N$199"
With ActiveSheet.PageSetup
.CenterHorizontally = True
.Orientation = xlLandscape
.FitToPagesWide = 1
End With
Range("H1").Select

MsgBox Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") & " pages will
be printed."

' If ExecuteExcel4Macro("GET.DOCUMENT(50)") <> 1 Then
Rows("59:59").Select
Range("B59").Activate
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Application.Run "PrintPage"
' Else
' Application.Run "PrintPage"
' End If

End Sub

Jim Cone said:
If you actually print the sheet, how many pages are printed?
Jim Cone



"Shawn777"
wrote in message
No, it didn't work. It just returns 4 pages each time.




Jim Cone said:
Here is the syntax I use...
(that still doesn't mean the count will be correct) <g>
'---
Sub LotsOfStrings()
Dim strWB As String
Dim strName As String
Dim strFiller As String
Dim lngCount As Long

strWB = "[" & ActiveWorkbook.Name & "]"
strName = Worksheets(23).Name
strFiller = "get.document(50,""" & strWB & strName & """)"
lngCount = ExecuteExcel4Macro(strFiller)
MsgBox lngCount
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
 
Make sure in your Page Setup for your worksheet, and make sure that in the scaling options, the option to 'Adjust To: x% normal size' is selected and not the 'Fit To: x pages wide' option.
 
Back
Top