V
vicw
I am having problems getting some VBA code to work and am confused by the
values being returned from Word. So far I have not found any helpful
information on the web or inseveral books (not encouraging!).
I use AuthorIT to publish to Word (2003 SP2) and am working on a document
the has mostly Portrtait pages, but has a couple of Landscape pages in the
middle. When the Landscape pages are published, their Page Setup is Portrait
/ Letter Rotated 8.5 x 11 (probably a mapping disconnect between AuthorIT and
Word??). When I try to print these pages, the printers (and I have tried
several) all prompt for 11 x 17 paper!
To overcome this problem, I am trying to write a macro to iterate through
the Sections and when I find a section that is defined as Portrait, but has a
Page Width of 11 inches I want to convert that section's page setup to
Portrait / 8.5 x 11.
Word seems to have a Construct for Portrait of 0 and Lanscape of 1. It also
seems to store page widths and heights in points instead of inches (maybe?),
since the values I receive are 612 and 792.1.
I have tried several things to change the section's page setup , but get
errors on the line indicated in the code below.
==================================================================
Sub ConverttoLandscape()
'
' AuthorIT publishes Landscape media objects to Word as Portrait/Letter
Rotated layouts
' These parameters must be changed to Landscape/Letter
'
Dim oSct As Section
Dim iSection As Integer
'
iSection = 1
'
For Each oSct In ActiveDocument.Sections
'
If oSct.PageSetup.Orientation = 0 And _
oSct.PageSetup.PageWidth = 792.1 Then
MsgBox "Found an illegitimate Portrait section!", vbOKOnly
'
With ActiveDocument.Sections(iSection).PageSetup
.Orientation = wdOrientLandscape ' errors and stops on
this line
.PageWidth = InchesToPoints(11)
.PageHeight = InchesToPoints(8.5)
End With
'
ElseIf oSct.PageSetup.Orientation = 0 And _
oSct.PageSetup.PageWidth = 612 Then
MsgBox "Found a legitimate Portrait section!", vbOKOnly
Else
MsgBox "Found a weird section!", vbOKOnly
End If
'MsgBox "Section " & iSection & " done.", vbOKOnly
'
iSection = iSection + 1
'
Next oSct
'
End Sub
================================================================
values being returned from Word. So far I have not found any helpful
information on the web or inseveral books (not encouraging!).
I use AuthorIT to publish to Word (2003 SP2) and am working on a document
the has mostly Portrtait pages, but has a couple of Landscape pages in the
middle. When the Landscape pages are published, their Page Setup is Portrait
/ Letter Rotated 8.5 x 11 (probably a mapping disconnect between AuthorIT and
Word??). When I try to print these pages, the printers (and I have tried
several) all prompt for 11 x 17 paper!
To overcome this problem, I am trying to write a macro to iterate through
the Sections and when I find a section that is defined as Portrait, but has a
Page Width of 11 inches I want to convert that section's page setup to
Portrait / 8.5 x 11.
Word seems to have a Construct for Portrait of 0 and Lanscape of 1. It also
seems to store page widths and heights in points instead of inches (maybe?),
since the values I receive are 612 and 792.1.
I have tried several things to change the section's page setup , but get
errors on the line indicated in the code below.
==================================================================
Sub ConverttoLandscape()
'
' AuthorIT publishes Landscape media objects to Word as Portrait/Letter
Rotated layouts
' These parameters must be changed to Landscape/Letter
'
Dim oSct As Section
Dim iSection As Integer
'
iSection = 1
'
For Each oSct In ActiveDocument.Sections
'
If oSct.PageSetup.Orientation = 0 And _
oSct.PageSetup.PageWidth = 792.1 Then
MsgBox "Found an illegitimate Portrait section!", vbOKOnly
'
With ActiveDocument.Sections(iSection).PageSetup
.Orientation = wdOrientLandscape ' errors and stops on
this line
.PageWidth = InchesToPoints(11)
.PageHeight = InchesToPoints(8.5)
End With
'
ElseIf oSct.PageSetup.Orientation = 0 And _
oSct.PageSetup.PageWidth = 612 Then
MsgBox "Found a legitimate Portrait section!", vbOKOnly
Else
MsgBox "Found a weird section!", vbOKOnly
End If
'MsgBox "Section " & iSection & " done.", vbOKOnly
'
iSection = iSection + 1
'
Next oSct
'
End Sub
================================================================