ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Page set up from VB6 (https://www.excelbanter.com/excel-programming/273784-page-set-up-vb6.html)

Chris H[_2_]

Page set up from VB6
 
I have a Visual Basic 6 program thet outputs data to an
excell work sheet, but get an error when trying to set the
page up prior to printing:
err 1004:
Unable to set the printArea property of the PageSetup class

Can someone please help? Many thanks.

Dim objXL As Object
Dim objWB As Object
Dim objWS As Object

Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.Workbooks.Add
Set objWS = objWB.ActiveSheet

sRange = "A1:H" & iXrow
objWS.PageSetup.PrintArea = sRange
objWS.PageSetup.PrintGridlines = True
objWS.PageSetup.Orientation = xlLandscape
objWS.Range("A1:H1").Interior.ColorIndex = 15

William[_2_]

Page set up from VB6
 
Hi Chris

You haven't defined "iXrow in the line "sRange = "A1:H" & iXrow"

--
XL2002
Regards

William


"Chris H" wrote in message
...
| I have a Visual Basic 6 program thet outputs data to an
| excell work sheet, but get an error when trying to set the
| page up prior to printing:
| err 1004:
| Unable to set the printArea property of the PageSetup class
|
| Can someone please help? Many thanks.
|
| Dim objXL As Object
| Dim objWB As Object
| Dim objWS As Object
|
| Set objXL = CreateObject("Excel.Application")
| Set objWB = objXL.Workbooks.Add
| Set objWS = objWB.ActiveSheet
|
| sRange = "A1:H" & iXrow
| objWS.PageSetup.PrintArea = sRange
| objWS.PageSetup.PrintGridlines = True
| objWS.PageSetup.Orientation = xlLandscape
| objWS.Range("A1:H1").Interior.ColorIndex = 15




All times are GMT +1. The time now is 12:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com