I've written an add-in for MS Word which adds a commandbarbutton, and fires a form when clicked.
I'm having some trouble sending the Word application object to the form, so that it can work with my Word document.
Conceptual code looks like this:
file: connect.vb
file mainform.vbCode:public class Dim withevents SuperForm as Windows.Forms.Form Dim applicationObject as Object applicationObject = application private sub button_click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles Button.Click SuperForm = New Mainform SuperForm.Show() end sub end class
How can I send the current Word application object to the new form I'm creating?Code:Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim oWord As Word.Application oWord = CType(applicationObject, Word.Application) ...
Is is correct to use something like this?:
Code:Public MainForm(ByRef applicationObject As Object) and SuperForm = new MainForm(applicationObject)




Reply With Quote