Consulting

Results 1 to 7 of 7

Thread: Non Global Templates as AddIns

  1. #1

    Non Global Templates as AddIns

    For various reasons, I have a document which attaches to a non-global Add-In, and no I cannot change it to be global.

    We try to open a 2nd document and attach it to the same addin and it does not error out, it just does not attach?

    Can we
    1) Attach to the Add-In existing in memory?
    2) Create a copy with a new project name, so there is no confusion in which code to read?

    The first method if possible I think is better. Thanks for anyone's help.

  2. #2
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    How are you attaching it? Are you changing the .AttachedTemplate property?

    Or are you attempting to load the addin as a global addin, but not from a location your macro security accepts as "safe"?

    There's a difference.

  3. #3
    Actually by making a copy and using the .attachedtemplate property seems to be working for me, so I may go with that.

    But as always, thanks for your help.

  4. #4

    Still a problem

    Actually it unfortunately only sort of worked. the template is still attached and that causes the problem.

    No, it is not a global add-in since we need to release it to update it, so we just use a simple

    Application.Addins.add ("Repository.dot")

  5. #5
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    I'm confused. I think you're mixing up concepts here.

    AttachedTemplate refers to the macro project attached (and available) to a document. As an example-- having a Letter.dot which has code in it. You can, of course, have multiple documents open which reference the letter.dot (i.e., multiple open documents with .AttachedTemplate = "C:\SomeFolder\Letter.dot")

    If you're using the Application.Addins.Add method... then you are loading a global addin -- which you would only do once (you don't load a global addin multiple times). The fact that it doesn't "auto load" (i.e., load on startup) is defining a different kind of behavior... but it's still a "global addin" with its code accessible to all documents until it is unloaded (whether from quitting Word or manually unloading it).

    Since I'm not 100% what you're trying to do, it's tough to know how to help... I can only explain the concepts.

    Another thing to know is that if you change the .AttachedTemplate property of a document via code, and that is the *only* document open which is referencing that template/project (i.e., you have a letter document based on your letter template, and then you use letter project code to change the attached template), you will have issues. The project will appear to close, and further code will stop executing, but the application will leave a reference to the project because (I assume) it had such an ungraceful exit.

    What are you trying to do? Unload something in order to update it? I think you might be running into self-referential issues here.

  6. #6
    I may be a little confused on concepts, but the following was not working.

    Addin Named R

    Form A added-in Addin R and run a AutoOpen from R fine.

    While Form A is Open,
    We Opened Form B.

    Form B has coded to add-in Addin R, and run AutoOpen from R.

    While it did not error out, it did not run AutoOpen from R.

    In theory, based on what you said, it should have, so I was trying to figure out what direction to go.

  7. #7
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    When you say "Form A" and "Form B" -- are those UserForms? Or are they Documents/Templates?

    I'm guessing the "forms" are actually "form documents" ... So how are you running the AutoOpen? By creating new documents based on the templates?

    There are a couple ways to go about this, but I don't feel like I totally understand what you're doing yet to do more than suggest checking the Application.Addins collection before trying to load an addin which is already loaded.

    But if you're trying to change the .AttachedTemplate property... that's entirely different.

    You may need to upload a mock up of your architecture to really get an answer. It's hard to give you direction when we're not describing things in the same way.

Posting Permissions

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