Visio2000: Sample Macro to Export a Region in a Drawing to a Graphic Format (291195)



The information in this article applies to:

  • Microsoft Visio 2000 Standard Edition
  • Microsoft Visio 2000 Professional Edition
  • Microsoft Visio 2000 Technical Edition
  • Microsoft Visio 2000 Enterprise Edition

This article was previously published under Q291195

SUMMARY

This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) that selects a set of shapes in a given drawing region and exports them to a graphics file.

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 gets a selection object of all Visio shapes in a region of a drawing page, and then exports them to a graphics format.

The example gets all the shapes in the upper-right quadrant of an 8.5-by-11 page.

NOTE: When you call the Export method, Visio uses the same graphics filter options that the user chose the last time a file was saved in that format. You cannot change these options programmatically in Visio 2000.
Public Sub SaveRegionDemo()

Dim selectRegion As Visio.Selection
Dim shpBoundingRect As Visio.Shape

' Draw a rectangle that covers the quadrant that we want to save.
Set shpBoundingRect = ActivePage.DrawRectangle(4.25, 11, 8.5, 5.5)

' Get a selection object that contains all shapes that share space with the 
' rectangle.
Set selectRegion = _
shpBoundingRect.SpatialNeighbors(visSpatialOverlap + visSpatialContain, 0, 0)

' Comment the previous line and uncomment the next one if you want to 
' save only shapes that are completely within the boundary rectangle:
' Set selQuadrant = shpBoundingRect.SpatialNeighbors(visSpatialContain, 0, 0)

shpBoundingRect.Delete

selectRegion.Export ("c:\test.bmp")

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 Visio2000: How to Run Sample Code from Knowledge Base Articles

Or, go to the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/17/2005
Keywords:kbhowto KB291195