Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to insert a page break in a Excel sheet ?

Status
Not open for further replies.

pxw

Programmer
Jan 6, 2002
86
AU
Could someone tell me how to insert a page break in a Excel sheet using VFP, please? Following is my codes,

sfile=Fullpath('EST.xls')
oExcel=CreateObject("Excel.Application")
oExcel.visible=.T.
oExcel.Workbooks.Open(sfile)

WITH oExcel
oSheet = oExcel.ActiveSheet
.range("F3").Value ="ABC"
* need to add a pagebreak here.**
ENDWITH
oExcel.Quit()

 
Try this:
Code:
sfile=Fullpath('EST.xls')
oExcel=CreateObject("Excel.Application")
oExcel.visible=.T.         
oExcel.Workbooks.Open(sfile)            
xlPageBreakManual = -4135
WITH oExcel
    oSheet = oExcel.ActiveSheet
    .range("F3").Value  ="ABC"
    .rows(4).pagebreak = xlPageBreakManual
    .columns("G").pagebreak = xlPageBreakManual
ENDWITH
oExcel.Quit()
hope this helps
Andreas
 
in the future, take a look at FAQ184-2215.

this may help guide you to finding the method and properties of excel Attitude is Everything
 
Andreas,
Fantastic.....It works! Many thanks. By the way, what is the meaning of the number -4135 in your codes and where do you get it from?

danceman,
thanks for the information. You have helped me many times.



Peter
 
Peter,
The number -4135 is the number behind the Excel-Constant xlPageBreakManual. I looked up the example of how to insert a pagebreak in Excel and in the example there was this constant. In the immediate-window of VBA I typed ?xlPageBreakManual and the number it displayed is the number -4135, so I knew which number you have to assign. Unfortunately I don't know where to look them up all together. Maybe someone else knows an entire list of the constants and the numbers behind them.

Andreas
 
by using the object browser as referenced by faq184-2215, you can see all constants with their assignments. I used it to confirm your posting. Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top