J
Josh Asbury
Hi all -
I am having troubles with implementing a CommandBar in Microsoft Word
utilizing VB.net. My CommandBar appears when I start Word, but if I open an
existing document, it does not appear. My best guess is that ActiveDocument
isn't getting set correctly, but I really don't know how else to implement
this. I am attaching an external template to avoid making any changes to
Normal.dot, but my code generates the CommandBar. I have included a snip of
OnStartupComplete and OnConnection below for your inspection.
Any help with this would be *very* appreciated. My deadline is in a couple
of hours and I just discovered this little "feature" a couple of days ago
and haven't been able to resolve it.
Thanks!
Josh
Imports Office.MsoControlType
Imports Office.MsoButtonStyle
Imports Office.MsoTriState
Imports Office
Imports Word
Friend WithEvents ThisDocument As Word.Document
Friend WithEvents ThisApplication As Word.Application
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim applicationObject as Object
dim addInInstance as object
.......................
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
******* FAILS HERE *****
ThisDocument = applicationObject.ActiveDocument
******* FAILS HERE *****
Dim myTemplate As Template
ThisDocument.AttachedTemplate = "C:\TempWord Add-In\BCC.dot"
myTemplate = ThisDocument.AttachedTemplate
MsgBox(myTemplate.Path & applicationObject.PathSeparator _
& myTemplate.Name)
.......
Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
ThisApplication = application
applicationObject = application
addInInstance = addInInst
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
Then _
Call OnStartupComplete(custom)
End Sub
I am having troubles with implementing a CommandBar in Microsoft Word
utilizing VB.net. My CommandBar appears when I start Word, but if I open an
existing document, it does not appear. My best guess is that ActiveDocument
isn't getting set correctly, but I really don't know how else to implement
this. I am attaching an external template to avoid making any changes to
Normal.dot, but my code generates the CommandBar. I have included a snip of
OnStartupComplete and OnConnection below for your inspection.
Any help with this would be *very* appreciated. My deadline is in a couple
of hours and I just discovered this little "feature" a couple of days ago
and haven't been able to resolve it.
Thanks!
Josh
Imports Office.MsoControlType
Imports Office.MsoButtonStyle
Imports Office.MsoTriState
Imports Office
Imports Word
Friend WithEvents ThisDocument As Word.Document
Friend WithEvents ThisApplication As Word.Application
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim applicationObject as Object
dim addInInstance as object
.......................
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
******* FAILS HERE *****
ThisDocument = applicationObject.ActiveDocument
******* FAILS HERE *****
Dim myTemplate As Template
ThisDocument.AttachedTemplate = "C:\TempWord Add-In\BCC.dot"
myTemplate = ThisDocument.AttachedTemplate
MsgBox(myTemplate.Path & applicationObject.PathSeparator _
& myTemplate.Name)
.......
Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
ThisApplication = application
applicationObject = application
addInInstance = addInInst
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
Then _
Call OnStartupComplete(custom)
End Sub