Microsoft Knowledge Base Email Alertz

KBAlertz.com: This article explains how to duplicate a page, along with the shapes on that particular page, by using Microsoft Visual Basic for Applications. The sample code also provides an example of how to use the Page.PageSheet property to get access to a

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **


Community Site



We Send hundreds of thousands of emails using ASP.NET Email


ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 289859 - Last Review: January 31, 2007 - Revision: 2.3

Visio2000: Sample Macro to Duplicate a Page

This article was previously published under Q289859
For a Microsoft Visio 2002 version of this article, see 290581  (http://kbalertz.com/Feedback.aspx?kbNumber=290581/EN-US/ ) .

On This Page

SUMMARY

This article explains how to duplicate a page, along with the shapes on that particular page, by using Microsoft Visual Basic for Applications. The sample code also provides an example of how to use the Page.PageSheet property to get access to a page's ShapeSheet cells.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Sample Code

The following sample code duplicates a page:
Public Sub DuplicateActivePage()
    Dim OriginalPage As Visio.Shape
    Dim DuplicatePage As Visio.Shape
    
    Dim ShapeDropX As Double
    Dim ShapeDropY As Double
    
    Set OriginalPage = ActivePage.PageSheet
    ActiveWindow.SelectAll ' Select everything on the first page...
    ActiveWindow.Group ' ...then group it all...
    ActiveWindow.Copy ' ... then copy it to the Clipboard.
    
    ShapeDropX = ActiveWindow.Selection(1).Cells("PinX") 
    ' Get the new Group's x position.

    ShapeDropY = ActiveWindow.Selection(1).Cells("PinY") 
    ' Get the new Group's y position.
    
    Set DuplicatePage = ActiveDocument.Pages.Add.PageSheet 
    ' Create the new page.
    
    ' Set attributes of the new page to be the same as the original page.
    With DuplicatePage
        .Cells("PageWidth") = OriginalPage.Cells("PageWidth")
        .Cells("PageScale") = OriginalPage.Cells("PageScale")
        .Cells("ShdwOffsetX") = OriginalPage.Cells("ShdwOffsetX")
        .Cells("PageHeight") = OriginalPage.Cells("PageHeight")
        .Cells("DrawingScale") = OriginalPage.Cells("DrawingScale")
        .Cells("ShdwOffsetY") = OriginalPage.Cells("ShdwOffsetY")
        .Cells("DrawingSizeType") = OriginalPage.Cells("DrawingSizeType")
        .Cells("DrawingScaleType") = OriginalPage.Cells("DrawingScaleType")
        .Cells("InhibitSnap") = OriginalPage.Cells("InhibitSnap")
        .Cells("PlaceStyle") = OriginalPage.Cells("PlaceStyle")
        .Cells("PlaceDepth") = OriginalPage.Cells("PlaceDepth")
        .Cells("PlowCode") = OriginalPage.Cells("PlowCode")
        .Cells("ResizePage") = OriginalPage.Cells("ResizePage")
        .Cells("DynamicsOff") = OriginalPage.Cells("DynamicsOff")
        .Cells("EnableGrid") = OriginalPage.Cells("EnableGrid")
        .Cells("CtrlAsInput") = OriginalPage.Cells("CtrlAsInput")
        .Cells("LineAdjustFrom") = OriginalPage.Cells("LineAdjustFrom")
        .Cells("BlockSizeX") = OriginalPage.Cells("BlockSizeX")
        .Cells("BlockSizeY") = OriginalPage.Cells("BlockSizeY")
        .Cells("AvenueSizeX") = OriginalPage.Cells("AvenueSizeX")
        .Cells("AvenueSizeY") = OriginalPage.Cells("AvenueSizeY")
        .Cells("RouteStyle") = OriginalPage.Cells("RouteStyle")
        .Cells("PageLineJumpDirX") = OriginalPage.Cells("PageLineJumpDirX")
        .Cells("PageLineJumpDirY") = OriginalPage.Cells("PageLineJumpDirY")
        .Cells("LineAdjustTo") = OriginalPage.Cells("LineAdjustTo")
        .Cells("LineToNodeX") = OriginalPage.Cells("LineToNodeX")
        .Cells("LineToNodeY") = OriginalPage.Cells("LineToNodeY")
        .Cells("LineToLineX") = OriginalPage.Cells("LineToLineX")
        .Cells("LineToLineY") = OriginalPage.Cells("LineToLineY")
        .Cells("LineJumpFactorX") = OriginalPage.Cells("LineJumpFactorX")
        .Cells("LineJumpFactorY") = OriginalPage.Cells("LineJumpFactorY")
        .Cells("LineJumpCode") = OriginalPage.Cells("LineJumpCode")
        .Cells("LineJumpStyle") = OriginalPage.Cells("LineJumpStyle")
        .Cells("XRulerOrigin") = OriginalPage.Cells("XRulerOrigin")
        .Cells("YRulerOrigin") = OriginalPage.Cells("YRulerOrigin")
        .Cells("XRulerDensity") = OriginalPage.Cells("XRulerDensity")
        .Cells("YRulerDensity") = OriginalPage.Cells("YRulerDensity")
        .Cells("XGridOrigin") = OriginalPage.Cells("XGridOrigin")
        .Cells("YGridOrigin") = OriginalPage.Cells("YGridOrigin")
        .Cells("XGridDensity") = OriginalPage.Cells("XGridDensity")
        .Cells("YGridDensity") = OriginalPage.Cells("YGridDensity")
        .Cells("XGridSpacing") = OriginalPage.Cells("XGridSpacing")
        .Cells("YGridSpacing") = OriginalPage.Cells("YGridSpacing")
    End With
    
    ActivePage.Paste ' Paste the copied group from the Clipboard.
    ActiveWindow.Selection(1).Cells("PinX") = ShapeDropX 
    'Position the group.
    ActiveWindow.Selection(1).Cells("PinY") = ShapeDropY
    ActiveWindow.Selection(1).Ungroup 'Ungroup the group.
    
    ActiveWindow.Page = OriginalPage.ContainingPage.Name 
    ' Go back to the original page...

    ActiveWindow.SelectAll ' ...then select the group...
    ActiveWindow.Selection(1).Ungroup '...and ungroup it...
    ActiveWindow.DeselectAll ' and then deselect all of the shapes.
    
    MsgBox DuplicatePage.ContainingPage.Name & " has been created."
End Sub
				

REFERENCES

For additional information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
277011  (http://kbalertz.com/Feedback.aspx?kbNumber=277011/EN-US/ ) Visio2000: How to Run Sample Code from Knowledge Base Articles
Or, go to the following Microsoft Web site:
MSDN Online Visio Development Center (http://msdn.microsoft.com/visio/)

APPLIES TO
  • Microsoft Visio 2000 Standard Edition
  • Microsoft Visio 2000 Professional Edition
  • Microsoft Visio 2000 Technical Edition
  • Microsoft Visio 2000 Enterprise Edition
Keywords: 
kbdtacode kbhowto KB289859
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please