Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts

    I am inside the VBA code for an add-in; How can it (Word 2003 VBA)

    Hi all,

    I am inside the VBA code for an add-in; How can it get the full path name of the add-in (its own) ?

    I suppose I could do it this way: since I know the name of the add-in file name, then I could apply that to the Addins collection, and get the components of the full path name, like this:

    WWL_Dot_FileName = AddIns("WWL - Working Word Lists - ed0-02 E.dot").Name
    WWL_Dot_FileName = AddIns("WWL - Working Word Lists - ed0-02 E.dot").Path

    and so then I can construct what I want.

    However, apart from not being so elegant, you can see from the code sample above that while I am developing the add-in, I make copies of the various drafts of the add-in file and increment its draft number, so its file name is always changing.

    So is there a way of saying something like:
    ThisAddin.FullPathName
    ?

    Tia,


    Actually, I have just found that the statement

    AddIns("WWL - Working Word Lists - ed0-02 E.dot").

    does not return the add-in.

    It tells me "The requested member of the collection does not exist."

    Even if I take the blanks out of the file name (and the string above) it still does not work.

    That's pretty bad: now I don't have anything to fall back on.

    Tia


    -avi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: I am inside the VBA code for an add-in; How can it (Word 2003 VBA)

    You can use

    ThisDocument.FullName

    to retrieve the path and filename of the add-in. ThisDocument refers to the document or template that contains the code.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: I am inside the VBA code for an add-in; How ca

    I've also seen people use MacroContainer, but I'm not sure whether there is any advantage to one technique or the other.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: I am inside the VBA code for an add-in; How ca

    MacroContainer works in documents and in document templates, but not in global templates (add-ins) - it returns "property not supported", at least in Word 2002. I have no idea why.
    ThisDocument works in documents, document templates and global templates.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: I am inside the VBA code for an add-in; How ca

    Thanks! Someday I will need to remember that. [gin]

  6. #6
    2 Star Lounger
    Join Date
    Dec 2007
    Posts
    179
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: I am inside the VBA code for an add-in; How can it (Word 2003 VBA)

    As easy as that, eh?

    Great!

    Thanks, Hans!

    Avi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •