Results 1 to 7 of 7

Thread: VB Add-In for Word2000

  1. #1

    Thread Starter
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    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!

    r0ach™
    Don't forget to rate the post

  2. #2
    Guest

    Post

    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

  3. #3

    Thread Starter
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    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.

    r0ach™
    Don't forget to rate the post

  4. #4
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Post

    Please post the code in the button's click event and we'll have a look...

  5. #5

    Thread Starter
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    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

    r0ach™
    Don't forget to rate the post

  6. #6
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Post

    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.

  7. #7

    Thread Starter
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    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).

    r0ach™
    Don't forget to rate the post

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