Changing Page Orientation

D

Dinesh

hi
I am using Visio 2003 Active X control in C#.Net .....I wanted to change the
Page Orientation of the Visio Diagram from Potrait to Landscape...
Any help/idea will be a help to me

thanks

dinesh
 
A

AlEdlund

when I click the page orientation button on the page setup panel to change
from portrait to landscape it appears that all that happens is that the
pagewidth and pageheight values are switched in the pagesheet.
al
 
D

Dinesh

hi Al
I'm not able to find out PageWidth and PageHeight in the PageSheet of the
Page ..

thanks

dinesh
 
A

AlEdlund

Public Sub changeOrientation()

On Error GoTo errhandler

Dim visPage As Visio.Page
Set visPage = Application.ActivePage
Dim visPageSheet As Visio.Shape
Set visPageSheet = visPage.PageSheet

Dim visCell As Visio.Cell
Dim dblTempX As Double
Dim dblTempY As Double

If visPageSheet.CellExists("pageheight", False) = True Then
dblTempX = visPageSheet.Cells("pageheight")
Else
Debug.Print "oops"
End If

If visPageSheet.CellExists("pagewidth", False) = True Then
dblTempY = visPageSheet.Cells("pagewidth")
Else
Debug.Print "oops"
End If

visPageSheet.Cells("pagewidth").Formula = dblTempX
visPageSheet.Cells("pageheight").Formula = dblTempY

Debug.Print dblTempX & " " & dblTempY

Exit Sub

errhandler:

Debug.Print Err.Description

End Sub
 
G

G-Money

I believe you also want to set the pageorientation.

Application.ActivePage.PageSheet.CellsSRC(visSectionObject,
visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU =
"2" 'landscape

or

Application.ActivePage.PageSheet.CellsSRC(visSectionObject,
visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU =
"1" 'portrait

This is just the output of the macro recorder. Seems like there
should be a predefined "vis" variable for "2" and "1". If you do not
set the orientation it could confuse the printer when you print the
drawing.

Thanks.
Garrett
 
G

G-Money

In addition, I like to reset the margins when my page orientation
changes if they are not all the same.

Application.ActivePage.PageSheet.Cells("PageLeftMargin").Formula = 1
Application.ActivePage.PageSheet.Cells("PageTopMargin").Formula = 1
Application.ActivePage.PageSheet.Cells("PageRightMargin").Formula = .
75
Application.ActivePage.PageSheet.Cells("PageBottomMargin").Formula = .
5

Hope this helps.
Garrett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top