G
gandalf
Hi,
I need a macro to convert, from the cursor location till the end of the document, all the pages from portrait to alndcape (or viceversa) and resize correctly all the tables in the pages.
I wrote something like this:
----------------------------------------
Dim rowRow as Row
Dim cllCell as Cell
Dim lngWidthUsable as Long
Dim lngWidthTable as Long
Dim tblTable as Table
Selection.InsertBreak wdSectionBreakNextPage
Selection.Start = Selection.Start + 1
With Selection.Sections(1).Range.PageSetup
.Orientation = wdOrientlandscape
.SectionStart = wdSectionNewPage
.DifferentFirstPageHeaderFooter = false
End with
With ActiveDocument.PageSetup
lngWidthUsable = .PageWidth - .LeftMargin - .RightMargin
End With
For Each tblTable In Selection.Sections(1).Range.Tables
For Each cllCell in tblTable.Rows(1).Cells
lngWidthTable = lngWidthTable + cllCell.Width
Next cllCell
For Each rowRow in tblTable.Rows
For Each cllCell In rowRow.Cells
cllCell.Width = cllCell.Width * (lngWidthUsable / lngWidthTable)
Next cllCell
Next rowRow
Next tblTable
--------------------------------------------------------------------------
I cannot check if this code makes the job because the .PageWidth and .LeftMargin give me a strange 99999 value (while the .RightMargin gives me the correct value).
Any hint/idea/help/suggetsion/code?
Thanks
I need a macro to convert, from the cursor location till the end of the document, all the pages from portrait to alndcape (or viceversa) and resize correctly all the tables in the pages.
I wrote something like this:
----------------------------------------
Dim rowRow as Row
Dim cllCell as Cell
Dim lngWidthUsable as Long
Dim lngWidthTable as Long
Dim tblTable as Table
Selection.InsertBreak wdSectionBreakNextPage
Selection.Start = Selection.Start + 1
With Selection.Sections(1).Range.PageSetup
.Orientation = wdOrientlandscape
.SectionStart = wdSectionNewPage
.DifferentFirstPageHeaderFooter = false
End with
With ActiveDocument.PageSetup
lngWidthUsable = .PageWidth - .LeftMargin - .RightMargin
End With
For Each tblTable In Selection.Sections(1).Range.Tables
For Each cllCell in tblTable.Rows(1).Cells
lngWidthTable = lngWidthTable + cllCell.Width
Next cllCell
For Each rowRow in tblTable.Rows
For Each cllCell In rowRow.Cells
cllCell.Width = cllCell.Width * (lngWidthUsable / lngWidthTable)
Next cllCell
Next rowRow
Next tblTable
--------------------------------------------------------------------------
I cannot check if this code makes the job because the .PageWidth and .LeftMargin give me a strange 99999 value (while the .RightMargin gives me the correct value).
Any hint/idea/help/suggetsion/code?
Thanks