DPrometheus
Well-known member
Hello there,
The problem is the following:
How can I pass a Word.Document object from vba code to vb.net?
I have made a small program which wraps Word 2007 into a usercontrol (custom panel) but now I want to interact with the document I ran into some problems..
For some other customizations (extra buttons on the new Ribbon) I cannot call the function with correct parameters it seems.
I cannot pass the Word.Document object from vba to vb.net for some reason I dont know.
Can someone shine a light for me here?
vb.net
VBA
The library seems linked correctly (The form is shown (a toolbar, as you might have guessed ) when the button is pressed, but as soon as the toolbar buttons are clicked it says object reference not set on the Word.Document object).
Can someone explain me what Im doing wrong?
Kind regards,
~DP
The problem is the following:
How can I pass a Word.Document object from vba code to vb.net?
I have made a small program which wraps Word 2007 into a usercontrol (custom panel) but now I want to interact with the document I ran into some problems..
For some other customizations (extra buttons on the new Ribbon) I cannot call the function with correct parameters it seems.
I cannot pass the Word.Document object from vba to vb.net for some reason I dont know.
Can someone shine a light for me here?
vb.net
Code:
Public Class EcfToolForm
Private _document As Word.Document
Public Sub New()
This call is required by the Windows Form Designer.
InitializeComponent()
Add any initialization after the InitializeComponent() call.
End Sub
This one doesnt work since vba cant use parameterized constructors
Public Sub New(ByRef doc As Word.Document)
InitializeComponent()
_document = doc
End Sub
Extra function to replace above constructor. This now must be called after the constructor has been called.
Public Sub LoadDoc(ByRef doc As Word.Document)
_document = doc
End Sub
...
VBA
Code:
Sub SpecialistButton_Click(control As IRibbonControl)
On Error Resume Next
Set toolbar = New Specialist07.EcfToolForm
toolbar.LoadDoc (Word.ActiveDocument)
toolbar.Show
Err.Clear
End Sub
The library seems linked correctly (The form is shown (a toolbar, as you might have guessed ) when the button is pressed, but as soon as the toolbar buttons are clicked it says object reference not set on the Word.Document object).
Can someone explain me what Im doing wrong?
Kind regards,
~DP