Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting the page?

Status
Not open for further replies.

Alcedes

Technical User
Mar 25, 2008
46
US
How can i format only the page being viewed currently?

I have figured out how to format the entire document....but this takes a large amount of time.

This is the code i have now (Like i said, it formats all pages)


Application.ActiveDocument.PaperSize = visPaperSizeA3
Application.ActiveDocument.PrintFitOnPages = True
Application.ActiveDocument.PrintLandscape = True
Application.ActiveDocument.PrintPagesAcross = 1
Application.ActiveDocument.PrintPagesDown = 1


I cannot find a way to do the exact same thing but to ONLY the page currently being viewed. Any ideas?
 
You are working at teh document level and should be working at the page level. Unfortunately, the page level does not have the nice properties of the document level and you will have to change the properties as cells.

So you need to use ActivePage.

Here is some sample code for changing the page height and width. Landscape / Portrait are not needed because H/W defines which one it is. To find other options, use the macro recorder.

Public Sub PageSize()

' This routine will change the paper size
Debug.Print ActivePage.Shapes("thePage").Cells("PageWidth")
Debug.Print ActivePage.Shapes("thePage").Cells("PageHeight")

ActivePage.Shapes("thePage").Cells("PageWidth").Formula = 7.5
ActivePage.Shapes("thePage").Cells("PageHeight").Formula = 15

Debug.Print ActivePage.Shapes("thePage").Cells("PageWidth")
Debug.Print ActivePage.Shapes("thePage").Cells("PageHeight")

ActivePage.Shapes("thePage").Cells("PageWidth").Formula = 8.5
ActivePage.Shapes("thePage").Cells("PageHeight").Formula = 11

Debug.Print ActivePage.Shapes("thePage").Cells("PageWidth")
Debug.Print ActivePage.Shapes("thePage").Cells("PageHeight")

End Sub

John... Visio MVP - Visio.MVPs.org
 
Actually, this code here seems to work fine.

On Error GoTo 10
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Page Setup")
Application.ActivePage.Background = False
Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesOnPage).FormulaU = "1"
Application.EndUndoScope UndoScopeID1, True
Application.ActiveDocument.PrintOut visPrintFromTo, Application.ActivePage.Index, Application.ActivePage.Index, , , , , 1
Exit Sub
10
Whoops = MsgBox("An error has occured!", vbCritical + vbOKOnly)
 
Any line with UnDoscope is unnecessary. That code is added by the macro recorder so that changes could be backed out. A more judicious placement of the code can be determined by the user. (at the beginning or the end).
Also the "Application." can also be removed.

John... Visio MVP - Visio.MVPs.org
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top