void ThisDocument_PictureContentControlAfterAdd(Word.Images can move about freely in a Microsoft Word document by default, so to avoid frustration, use these options to keep them in place. For C#, you must also attach the ThisDocument_PictureContentControlAfterAdd event handler to the ContentControlAfterAdd event of the ThisDocument class. To use this code, paste it into the ThisDocument class in your project. This version is for a document-level customization. The following code example creates a new PictureContentControl for every native picture control that the user adds to the document. "VSTOPictureContentControl" + count.ToString()) If nativeControl.Type = Thenĭim tempControl As .PictureContentControl = _ If <= 0 Thenįor Each nativeControl As Word.ContentControl In vstoDoc.ContentControls If Me.ContentControls.Count pictureControls įoreach (Word.ContentControl nativeControl in vstoDoc.ContentControls) Private Sub CreatePictureControlsFromNativeControls() Private void CreatePictureControlFromNativeControl()įoreach (Word.ContentControl nativeControl in this.ContentControls) To use this code, paste it into the ThisDocument class in your project, and call the CreatePictureControlFromNativeControl method from the ThisDocument_Startup method. The following code example creates a new PictureContentControl for every native picture control that is in the document. For more information, see Adding Controls to Office Documents at Run Time.ĬontentControl is not a building block gallery (that is, the Type property of contentControl does not have the value .WdContentControlType.wdContentControlPicture). Use this method to add a new PictureContentControl at the current selection in the document at run time. private .PictureContentControl pictureControl1 To use this code, paste it into the ThisAddIn class in your project, and call the AddPictureControlAtSelection method from the ThisAddIn_Startup method. This version is for an application-level add-in that targets the. PictureControl1 = Me.Controls.AddPictureContentControl("pictureControl1")īitmap1 = New (imagePath, True) Private Sub AddPictureControlAtSelection() PictureControl1 = ("pictureControl1") īitmap1 = new (imagePath, true) ĭim pictureControl1 As .PictureContentControl Private void AddPictureControlAtSelection() To use this code, paste it into the ThisDocument class in your project, and call the AddPictureControlAtSelection method from the ThisDocument_Startup method. For more information, see Adding Controls to Office Documents at Run Time. Use this method to add a new PictureContentControl at a specified range in the document at run time. VstoDoc.Paragraphs(1).Range, "pictureControl2") VstoDoc.Paragraphs(1).Range.InsertParagraphBefore() If Me.Application.ActiveDocument Is Nothing Thenĭim vstoDoc As Document = (Me.Application.ActiveDocument) private .PictureContentControl pictureControl2 To use this code, paste it into the ThisAddIn class in your project, and call the AddPictureControlAtRange method from the ThisAddIn_Startup method. PictureControl2 = Me.Controls.AddPictureContentControl(Me.Paragraphs(1).Range, "pictureControl2")ĭim imagePath As String = My. & _īitmap2 = New (imagePath, True) Me.Paragraphs(1).Range.InsertParagraphBefore() String imagePath = (Į) + "\\picture.bmp" īitmap2 = new (imagePath, true) ĭim pictureControl2 As .PictureContentControl To use this code, paste it into the ThisDocument class in your project, and call the AddPictureControlAtRange method from the ThisDocument_Startup method. This example assumes that a file named picture.bmp exists in the %UserProfile%\My Documents folder (for Windows XP and earlier) or the %UserProfile%\Documents folder (for Windows Vista). The following code example adds a new PictureContentControl to the beginning of the document. A control with the same name is already in the ControlCollection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |