473,544 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ActiveDocument Not Getting Set

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
OnStartupComple te 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.MsoContr olType
Imports Office.MsoButto nStyle
Imports Office.MsoTriSt ate
Imports Office
Imports Word

Friend WithEvents ThisDocument As Word.Document
Friend WithEvents ThisApplication As Word.Applicatio n

Public Class Connect
Implements Extensibility.I DTExtensibility 2

Dim applicationObje ct as Object
dim addInInstance as object

............... ........
Public Sub OnStartupComple te(ByRef custom As System.Array) Implements
Extensibility.I DTExtensibility 2.OnStartupComp lete

******* FAILS HERE *****
ThisDocument = applicationObje ct.ActiveDocume nt
******* FAILS HERE *****

Dim myTemplate As Template
ThisDocument.At tachedTemplate = "C:\TempWor d Add-In\BCC.dot"
myTemplate = ThisDocument.At tachedTemplate

MsgBox(myTempla te.Path & applicationObje ct.PathSeparato r _
& myTemplate.Name )

.......

Public Sub OnConnection(By Val application As Object, ByVal connectMode
As Extensibility.e xt_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.I DTExtensibility 2.OnConnection
ThisApplication = application
applicationObje ct = application
addInInstance = addInInst

If (connectMode <> Extensibility.e xt_ConnectMode. ext_cm_Startup)
Then _
Call OnStartupComple te(custom)
End Sub


Nov 21 '05 #1
1 5603
So, here's the latest: I have put the following debug code into my
OnStartupComple te. When I start Word, the first MsgBox fires with "Document
1" in it. However, when I launch an existing document by double-clicking it
within Explorer, the else condition is called and the "No documents are
open" dialog fires. I'm clueless here. Is there a way that I can call
something like Documents.Add ( or something ) from within the else block and
activate the document from there?

Help!!!! SOS!!!

Thanks!
Josh
If applicationObje ct.Documents.Co unt >= 1 Then
MsgBox(applicat ionObject.Activ eDocument.Name)
Else
MsgBox("No documents are open")
End If
"Josh Asbury" <Jo********@spa mthisbuddy.yaho o.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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 OnStartupComple te 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.MsoContr olType
Imports Office.MsoButto nStyle
Imports Office.MsoTriSt ate
Imports Office
Imports Word

Friend WithEvents ThisDocument As Word.Document
Friend WithEvents ThisApplication As Word.Applicatio n

Public Class Connect
Implements Extensibility.I DTExtensibility 2

Dim applicationObje ct as Object
dim addInInstance as object

............... .......
Public Sub OnStartupComple te(ByRef custom As System.Array) Implements
Extensibility.I DTExtensibility 2.OnStartupComp lete

******* FAILS HERE *****
ThisDocument = applicationObje ct.ActiveDocume nt
******* FAILS HERE *****

Dim myTemplate As Template
ThisDocument.At tachedTemplate = "C:\TempWor d Add-In\BCC.dot"
myTemplate = ThisDocument.At tachedTemplate

MsgBox(myTempla te.Path & applicationObje ct.PathSeparato r _
& myTemplate.Name )

......

Public Sub OnConnection(By Val application As Object, ByVal connectMode
As Extensibility.e xt_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.I DTExtensibility 2.OnConnection
ThisApplication = application
applicationObje ct = application
addInInstance = addInInst

If (connectMode <> Extensibility.e xt_ConnectMode. ext_cm_Startup)
Then _
Call OnStartupComple te(custom)
End Sub

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6895
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on a type mismatch. It is positively because of the boolean(java primitive)parameter. It goes fine if I change this parameter to int or String. This...
3
2923
by: Ken Wilson | last post by:
I am currently working on a Visual Studio add-in. Does anyone know of a simple way to get the line number the cursor is on in the ActiveDocument? I don't necessarily need full code as long as someone can point me in the right direction. Thanks in advance. Ken Wilson Seeking viable employment in Victoria, BC
8
9993
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500...
1
2119
by: Killian | last post by:
All, I'm using a word application in ASP.net (server side) to open an existing document, do a mail merge on it and then serve the created document to the client. The problem I am having is when I open the word document using the Word.Application and I then try to access the ActiveDocument property I get an error message saying that...
0
1053
by: Killian | last post by:
All, I'm using a word application in ASP.net (server side) to open an existing document, do a mail merge on it and then serve the created document to the client. The problem I am having is when I open the word document using the Word.Application and I
3
3580
by: Samuel R. Neff | last post by:
DTE.ActiveDocument.Kind returns a guid as a string. I couldn't find any list of what pre-defined GUIDs would be returned and what document types they correspond to. Is there a list available? Thanks, Sam
0
1337
by: zenjarplan | last post by:
hi i write a addin with vs2005 for office word. how is it possible to convert a word.activedocument to a byte array without saving a temporary file to disk? thanks lot zenjar
0
2813
by: sumitsant | last post by:
We have some process which imports data from comma separated, plain text file into word template. Upon initiating ActiveDocument.MailMerge.OpenDataSource the process stucks some times (no error message is displayed), after killing the process and rerunning it it finishes successfully. We cannot predict when the process will stuck or finish...
0
7416
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7360
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7761
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7363
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5289
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3400
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
983
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.