Compartir a través de


Propiedad Window.Document (Visio)

Obtiene el objeto Document asociado a un objeto . Solo lectura.

Sintaxis

expresión. Documento

Expresión Variable que representa un objeto Window .

Valor devuelto

Documento

Comentarios

La propiedad Document de una ventana de galería de símbolos acoplada devuelve un objeto Document para la galería de símbolos situada en la parte superior de la ventana en ese momento. Si otra galería de símbolos reemplaza a la primera en la parte superior, el documento de la primera galería de símbolos se cerrará, por lo que la referencia a ella dejará de ser válida. Para obtener los mejores resultados, dé por hecho que las referencias de los documentos a las galerías de símbolos acopladas no son persistentes.

Si un objeto Window muestra que no hay documentos abiertos, no se devuelve ningún documento y no se genera ninguna excepción. La solución debe comprobar si se ha devuelto el valor Nothing después de haber recuperado la propiedad Document de un objeto Window.

Ejemplo:

La siguiente macro de Microsoft Visual Basic para Aplicaciones (VBA) muestra cómo utilizar la propiedad Document de varios objetos para recuperar datos sobre dichos objetos, y realiza las siguientes operaciones:

  • Agrega un objeto Document a la colección Documents y establece varias de las propiedades del objeto Document.

  • Obtiene la ventana y la página activas, dibuja un rectángulo en la página y coloca un patrón en el objeto Document para proporcionar varios objetos en los que trabajar.

  • Utiliza la propiedad Document para obtener el objeto Document asociado a cada uno de estos objetos.

 
Public Sub Document_Example() 
 
 Dim vsoDocument As Visio.Document 
 Dim vsoTempDocument As Visio.Document 
 Dim vsoPage As Visio.Page 
 Dim vsoShape As Visio.Shape 
 Dim vsoWindow As Visio.Window 
 Dim vsoMaster As Visio.Master 
 
 'Add a document to the Documents collection. 
 Set vsoDocument = Documents.Add("") 
 
 'Set the title of the document. 
 vsoDocument.Title = "My Document" 
 
 'Get the active window and active page. 
 Set vsoWindow = ActiveWindow 
 Set vsoPage = ActivePage 
 
 'Draw a rectangle on the page. 
 Set vsoShape = vsoPage.DrawRectangle(2, 2, 5, 5) 
 
 'Add a master. 
 Set vsoMaster = vsoDocument.Masters.Add 
 
 'Get the Document object associated with various other objects.'Get the Document object associated with the Window object. 
 Set vsoTempDocument = vsoWindow.Document 
 
 'Get the Title property of the Document object to verify that this is the same document we added earlier. 
 Debug.Print vsoTempDocument.Title 
 
 'Get the Document object associated with the Page object. 
 Set vsoTempDocument = vsoPage.Document 
 Debug.Print vsoTempDocument.Title 
 
 'Get the Document object associated with the Shape object. 
 Set vsoTempDocument = vsoShape.Document 
 Debug.Print vsoTempDocument.Title 
 
 'Get the Document object associated with the Master object. 
 Set vsoTempDocument = vsoMaster.Document 
 Debug.Print vsoTempDocument.Title 
 
End Sub

Soporte técnico y comentarios

¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.