Don't quote me on this but I *THINK* that the range also needs to be an object. Something like oRange = oleExcel.ActiveSheet.Range("U1") and then oleExcel.ActiveSheet.HPageBreaks.Location = oRange (its some time since I did this and somebody has borrowed my Excel VBA book). Hopefully, should point you in the right direction.
>I am creating a report with statistical information in an Excel file from VFP 6 using OLE Automation. I would to set up some Page Breaks within the Excel file, but am having difficulty doing so. Setting up Page Break Preview is fine using:
> oleExcel.ActiveWindow.VIEW = xlPageBreakPreview
> (where oleExcel is the Excel object)
>
>However manipulating Page Breaks is proving difficult giving the syntax Excel uses seems incompatible with VFP. I've tried many varieties, such as:
> oleExcel.ActiveSheet.VPageBreaks(1).Location = RANGE("U1")
> oleExcel.SET(ActiveSheet.HPageBreaks(1).Location) = RANGE("A47")
> oleExcel.ActiveSheet.VPageBreaks(1).DragOff Direction:=xlRight, RegionIndex:=5
> oleExcel.ActiveWindow.SelectedSheets.HPageBreaks.AddBefore=ActiveCell
>
>None of these work. If anyone can suggest ways to handle Page Breaks, I would be most grateful.
>
>
>Steve Smith