View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Carlos Lozano Carlos Lozano is offline
external usenet poster
 
Posts: 18
Default Pagebreaks problems - Urgent

Jim,

The original code had no declaration for nHeight. I thought about it and
declared it as double, but nothing changed.
I also tried using a direct assignment between both sheets to avoid using
variables with same results.

Thanks,

Carlos Lozano

"Jim Cone" wrote:

Carlos,

How do you have nHeight declared?
Have you tried it with it declared as a Single or Double?
Regards,
Jim Cone

"Carlos Lozano" wrote in message
...
Hi Jim,

Thank you for your feedback.

It would have been neat if I could replace several lines of code with only
one.
Unfortunately oSheet.Copy copies the whole oSheet object including any code.
The oSheet object has code that depends on a class defined in the current
workbook (the application). That class won't be in the new workbook, so it
fails on activation.

I found the problem for the mismatch of the pagebreaks. The original sheet
has a row size of 15.75, when assigned to the new exported sheet it takes
only the integer part, changing the location of the pagebreaks.

I was doing the following:
nHeight = oSheet.Cells(nMinRow, 1).RowHeight
.
.
Set oExpSheet = ActiveWorkbook.Sheets("Design Project")
oExpSheet.Select
Columns("A:V").Select
oExpSheet.Paste
oExpSheet.Range("A1", "A800").RowHeight = nHeight
oExpSheet.Range("A7").RowHeight = 21
.
.
The value in nHeight is the row height = 15.75, but when assigned to the range
on oExpSheet it truncates it to only 15.

I also tried the below direct assignment.
oExpSheet.Range("A1", "A800").RowHeight = oSheet.Cells(nMinRow, 1).RowHeight

The only way it works is by hard-coding the row height directly as:
oExpSheet.Range("A1", "A800").RowHeight = 15.75

This will give problems if the user changes the row size.

Thank you,

Carlos Lozano

"Jim Cone" wrote:

Carlos,

Instead of copying and pasting the range, why not
just copy the entire sheet as is, and not worry about
the formatting...

oSheet.Copy Befo=Workbooks(NewWorkBook).Worksheets(1)

Regards,
Jim Cone
San Francisco, USA