Pages.Add メソッド (Visio)

コレクションに新しいオブジェクトを追加します。

構文

追加

Pages オブジェクトを表す変数。

戻り値

Page

注釈

新しいオブジェクトのすべてのプロパティは 0 に初期化されます。したがって、設定する必要があるのは変更するプロパティのみです。

次のマクロは、Master オブジェクトを Masters コレクションに追加し、Page オブジェクトを Pages コレクションに追加する方法を示します。 さらに、図面、レイヤー、スタイル、イベント、アドオンを対応するコレクションに追加する方法についても示します。

このマクロを実行する前に、 Myfile.vsd を有効な .vsd ファイルに置き換え、 パス \ ファイル名filename への参照を、Visio プロジェクトの実行可能アドオン (EXE) への有効なパスまたはファイル名に置き換えます。 アドオンに渡す引数は不要です。

Public Sub Add_Example() 
 
 Dim vsoMasters As Visio.Masters 
 Dim vsoAddons As Visio.Addons 
 Dim vsoPages As Visio.Pages 
 Dim vsoEventList As Visio.EventList 
 Dim vsoLayers As Visio.Layers 
 Dim vsoLayer As Visio.Layer 
 Dim vsoStyles As Visio.Styles 
 
 Dim vsoDocument As Visio.Document 
 Dim vsoEvent As Visio.Event 
 Dim vsoMaster As Visio.Master 
 Dim vsoPage As Visio.Page 
 Dim vsoShape As Visio.Shape 
 Dim vsoStyle As Visio.Style 
 Dim vsoAddon As Visio.Addon 
 
 'Add a document based on the Basic Diagram template. 
 Set vsoDocument = Documents.Add("Basic Diagram.vst") 
 
 'Add a document based on a drawing (creates a copy of the drawing). 
 Set vsoDocument = Documents.Add("Myfile.vsd ") 
 
 'Add a document based on a stencil (creates a copy of the stencil). 
 Set vsoDocument = Documents.Add("Basic Shapes.vss") 
 
 'Add a document object based on no template. 
 Set vsoDocument = Documents.Add("") 
 
 'Get the Pages collection and add a page to the collection. 
 Set vsoPages = vsoDocument.Pages 
 Set vsoPage = vsoPages.Add 
 
 'Get the Masters collection and add a master to the collection. 
 Set vsoMasters = vsoDocument.Masters 
 Set vsoMaster = vsoMasters.Add 
 
 'Get the Layers collection and add a layer named "MyLayer" 
 'to the collection. 
 Set vsoLayers = vsoPage.Layers 
 Set vsoLayer = vsoLayers.Add("MyLayer") 
 
 'Draw a rectangle. 
 Set vsoShape = vsoPage.DrawRectangle(3, 3, 5, 6) 
 
 'Add this shape to MyLayer. The second argument is required but has 
 'no effect, because vsoShape is not a group shape. 
 vsoLayer.Add vsoShape, 0 
 
 'Add a style named "My FillStyle" to the Styles collection. 
 'This style is based on the Basic style and includes 
 'only a Fill style. 
 Set vsoStyles = vsoDocument.Styles 
 Set vsoStyle = vsoStyles.Add("My FillStyle", "Basic", False, False, True) 
 
 'Add a style named "My NoStyle" to the Styles collection. 
 'This style is based on no style and includes 
 'Text, Line, and Fill styles. 
 Set vsoStyle = vsoStyles.Add("My NoStyle", "", True, True, True) 
 
 'Add an add-on to the Addons collection. 
 Set vsoAddons = Visio.Addons 
 Set vsoAddon = vsoAddons.Add("path \filename ") 
 
 'Add a BeforeDeleteSelection event to the EventList collection 
 'of the document. The event will start your add-on, which 
 'takes no arguments. 
 Set vsoEventList = vsoDocument.EventList 
 Set vsoEvent = vsoEventList.Add(visEvtCodeBefSelDel, visActCodeRunAddon, _ 
 "filename ", "") 
 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。