Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Actualización: noviembre 2007
Mediante programación, puede copiar formas de una página de un documento y pegarlas en una nueva página del mismo documento. Puede decidir pegarlas en la ubicación predeterminada (el centro de la ventana activa) o en las mismas ubicaciones de coordenadas que en la página original.
Copiar y pegar formas
Para obtener detalles sobre el modelo de objetos, vea la documentación de referencia de VBA para los métodos Microsoft.Office.Interop.Visio.Shape.DrawRectangle, Microsoft.Office.Interop.Visio.Shape.DrawOval, Microsoft.Office.Interop.Visio.Shape.Copy y Microsoft.Office.Interop.Visio.Shape.Paste, y para el marcador Microsoft.Office.Interop.Visio.VisCutCopyPasteCodes.visCopyPasteNormal.
Para copiar formas en el centro de otra página
En el ejemplo siguiente se muestra cómo copiar las formas de la primera página y pegarlas en el centro de la segunda página.
Me.Application.Documents.Add("") Dim copyPage As Visio.Page Dim pastePage As Visio.Page Dim rectangle As Visio.Shape = Nothing Dim oval As Visio.Shape = Nothing Dim visioPages As Visio.Pages = Me.Application.ActiveDocument.Pages visioPages.Add() Try copyPage = visioPages(1) rectangle = copyPage.DrawRectangle(1.1, 2.2, 4.5, 6.7) oval = copyPage.DrawOval(1, 8.75, 3.5, 6.25) Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try Try pastePage = visioPages(2) rectangle.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNormal) pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNormal) oval.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNormal) pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNormal) Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Trythis.Application.Documents.Add(""); Visio.Page copyPage; Visio.Page pastePage; Visio.Shape rectangle = null; Visio.Shape oval = null; Visio.Pages visioPages = this.Application.ActiveDocument.Pages; visioPages.Add(); try { copyPage = visioPages[1]; rectangle = copyPage.DrawRectangle(1.1, 2.2, 4.5, 6.7); oval = copyPage.DrawOval(1, 8.75, 3.5, 6.25); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } try { pastePage = visioPages[2]; rectangle.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNormal); pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNormal); oval.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNormal); pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNormal); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); }
Copiar y pegar formas con las mismas posiciones
Para obtener detalles sobre el modelo de objetos, vea la documentación de referencia de VBA para los métodos Microsoft.Office.Interop.Visio.Shape.DrawRectangle, Microsoft.Office.Interop.Visio.Shape.DrawOval, Microsoft.Office.Interop.Visio.Shape.Copy y Microsoft.Office.Interop.Visio.Shape.Paste, y para el marcador Microsoft.Office.Interop.Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate.
Si necesita controlar el formato de la información pegada y (opcionalmente) establecer un vínculo a un archivo de origen (por ejemplo, un documento de Microsoft Office Word), utilice el método PasteSpecial.
Para copiar formas y sus ubicaciones en otra página
En el ejemplo siguiente se muestra cómo copiar las formas de la primera página y pegarlas en la segunda página con sus ubicaciones de coordenadas originales.
Me.Application.Documents.Add("") Dim copyPage As Visio.Page Dim pastePage As Visio.Page Dim rectangle As Visio.Shape = Nothing Dim oval As Visio.Shape = Nothing Dim visioPages As Visio.Pages = Me.Application.ActiveDocument.Pages visioPages.Add() Try copyPage = visioPages(1) rectangle = copyPage.DrawRectangle(1.1, 2.2, 4.5, 6.7) oval = copyPage.DrawOval(1, 8.75, 3.5, 6.25) Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try Try pastePage = visioPages(2) rectangle.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate) pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate) oval.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate) pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate) Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Trythis.Application.Documents.Add(""); Visio.Page copyPage; Visio.Page pastePage; Visio.Shape rectangle = null; Visio.Shape oval = null; Visio.Pages visioPages = this.Application.ActiveDocument.Pages; visioPages.Add(); try { copyPage = visioPages[1]; rectangle = copyPage.DrawRectangle(1.1, 2.2, 4.5, 6.7); oval = copyPage.DrawOval(1, 8.75, 3.5, 6.25); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } try { pastePage = visioPages[2]; rectangle.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate); pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate); oval.Copy(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate); pastePage.Paste(Visio.VisCutCopyPasteCodes.visCopyPasteNoTranslate); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); }
Vea también
Tareas
Cómo: Agregar formas a un documento de Visio