-
I've been working on this Word2000 Add-In in VB6, and i came across something weird (I think, but then again it's only my first Add-In). The Add-In has a toolbarbutton that places the current document's full path in the footer. My problem is that it only works for the first document created. If you open another document or create a new one, then the button acts like it doesn't fire the click event. Can someone please help me urgently, since my deadline is today!:eek:
-
Sorry - I can't help you on your question but I was just wondering what these add-ins are and how yo came to be making one.
Cheers
Mafro
-
An Add-In is a VB (or VC++ or VBA) program (ActiveX DLL) that uses the object model of a host program (MSOffice2000) to extend the capabilities of that program. It's like completely customizing certain things a program does, or creating brand new things for the program.
-
Please post the code in the button's click event and we'll have a look...
-
I don't think it's the button's code. I think it's got something to do with instances. If I close the first document (Document1) then I get "Object required" errors, when I click it. But i'll post the code anyway:
Code:
Private Sub oFooterBtn_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
Set wDoc = Word.Documents(oApp.ActiveDocument)
wDoc.Sections.First.Footers(wdHeaderFooterPrimary).Range.Font.Name = "Tahoma"
wDoc.Sections.First.Footers(wdHeaderFooterPrimary).Range.Font.Size = 8
wDoc.Sections.First.Footers(wdHeaderFooterPrimary).Range.Text = ""
wDoc.Sections.First.Footers(wdHeaderFooterPrimary).Range.InsertBefore wDoc.FullName
Set wDoc = Nothing
End Sub
-
It looks like the problem is that Word thinks you still want to add the footer to the first document, as errors occur when it is closed.
Try putting a msgbox in the button's code to display the name of the ActiveDocument.
You said that "the button acts like it doesn't fire the click event" - putting a msgbox in will tell whether the event fire or not as well.
-
benski.
Thanks. My suspicions were right. The button does not fire the event in the other documents. On the first doc, I get my MsgBox, but not on any of the other docs (opened or new). :(