Results 1 to 10 of 10

Thread: Sending an object to a form

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    54

    Resolved Sending an object to a form

    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
    Code:
    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
    file mainform.vb
    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)
    ...
    How can I send the current Word application object to the new form I'm creating?

    Is is correct to use something like this?:
    Code:
    Public MainForm(ByRef applicationObject As Object)
    and 
    SuperForm = new MainForm(applicationObject)
    Last edited by Frode; Jan 10th, 2005 at 05:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width