Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disappearing Code (Office 2000)

    I use a macro to link a group of cells in an Excel Spreadsheet to a template in Word (I was helped by members here). I attached the code shown below to a control button on a template called "Template 6". When I click on the button (after having copied in Excel an area of the spreadsheet) I establish a link that is positioned correctly on the Word template's page. The macro also unprotects and reprotects the template form. After I leave word and return, the button no longer works. The code remains on Template 6 but is no longer attached to the button. After an inteval of time, usually one day, the code disappears entirely. I use the Project explorer but cannot locate the code.
    I saved the template on our network and pointed to the folder as a template folder using Tools, Options, File Location, User Templates, Modify. I have no trouble bringing up the template with a File New command.

    Here's the code:

    Public Sub TestIt()
    ActiveDocument.Unprotect Password:="Test"
    Selection.GoTo What:=wdGoToBookmark, Name:="Text1"
    Selection.PasteSpecial Link:=True, DataType:=wdPasteOLEObject, _
    Placement:=wdInLine, DisplayAsIcon:=False
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    With Selection.InlineShapes(1)
    .Height = InchesToPoints(3.18)
    .Width = InchesToPoints(6.18)
    End With
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="Test"
    End Sub

  2. #2
    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: Disappearing Code (Office 2000)

    This sounds like several different problems. Let me see if I can summarize this.

    You created and saved Template 6.dot on a network share.

    [list=1]<LI>When you create a new document based on the template the same day, initially everything works, but after you close and re-open the document (or close and re-open Word?), the button no longer runs the macro.

    <UL><LI>What kind of button is this: toolbar, MACROBUTTON field, or ActiveX control?

    [list=1]<LI>Toolbar: make sure the toolbar button was created/saved in the context of Template 6.dot
    <LI>MACROBUTTON field: make sure Template 6.dot is still attached to the document.
    <LI>ActiveX: I've never used these, so I really don't know.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disappearing Code (Office 2000)

    The button is a "Control Button". I used the Tools Customize Control Tool box and dragged a "Command Button" on to the template. This is where I stored the macro. I don't know what you mean when you say make sure Template 6.dot is attached to the document. I'm opening the template with a File new command. Is there something else I should check?
    Do you mean I should test it on a local drive? I'll do this but saving the template on a local drive doesn't work for us because I want approximately 25 or more people to have access.
    I'm not sure what you mean by changing the path to a UNC path. I changed the path to the shared directory we are using for templates with a Tools Options File location User Template folder designation.
    I don't think any backup file is at work here.
    Thanks.

  4. #4
    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: Disappearing Code (Office 2000)

    > The button is a "Control Button". I used the Tools Customize Control Tool box and dragged a "Command Button"
    > on to the template. This is where I stored the macro.

    If you dragged the button onto a toolbar, I know about those. If you dragged it into the actual workspace of the document itself, those are the kind of buttons I don't know anything about. <img src=/S/frown.gif border=0 alt=frown width=15 height=15>

    > I don't know what you mean when you say make sure Template 6.dot is attached to the document. I'm opening the
    > template with a File new command. Is there something else I should check?

    File|Open opens files, and File|New creates new files. Normally, File|New will create a new document (e.g., Document1) based on (and attached to) the template you choose in that dialog. (Unless you click the choice to create a new template instead of a new document, in which case you'll get something like Template1.) Each document has only one "attached template" at a time, and it will be listed at the top of the dialog under Tools|Templates and Add-ins. (A template has no attached template; that area will be grayed out.) Unless you change it or Word can't find it, the attached template is the one you used to create the document back in the File|New dialog. Does any of this check out for the document/template you are creating with File|New?

    > I want approximately 25 or more people to have access. I'm not sure what you mean by changing the path to a UNC
    > path. I changed the path to the shared directory we are using for templates with a Tools Options File location User
    > Template folder designation.

    Okay, sorry I didn't explain this more fully. When Word opens a document, it will search for and load the attached template. This makes the macros in that template available to you (as well as other useful stuff, such as AutoText, custom toolbars, etc.). There are two kinds of paths to network folders: paths that start with a mapped drive letter, and paths written in UNC notation:

    F:FinanceTemplatesTemplate 6.dot
    BigServerPublicFinanceTemplatesTemplate 6.dot

    These are equivalent if your F drive maps to BigServerPublic. If your computer forgets its drive mappings or doesn't lock them in at the beginning of a session, the first notation can result in the template not being found. So I suggested using the longer UNC notation instead. You might have to type ServernameSharename part in manually.

    One other tip: you should point the Workgroup Templates folder to the shared folder, and keep the User Templates folder for personal use. That way, you won't accidentally weed out or overwrite someone's custom templates.

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disappearing Code (Office 2000)

    One thing to add to Jefferson's post. If you're opening a file based on a template (which is what you're doing when you choose File/New), you will NOT be able to see the code in the VBE. You must open the template itself before you can see the code contained in a module of that template.

  6. #6
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disappearing Code (Office 2000)

    Thank you both for the tips.
    The template is attached (appears as a checked field when I invoke Tools, Templates Add ins.
    The button is within the document.
    I will try the longer notation.
    I can find the code using the Project Explorer at home but not at work.
    One thing I did not mention is that in addition to this macro, I used the Spellcheck macro from the MVP web site and put it on my tool bar. This macro is saved in my Start Up file and works fine for documents based on this protected form template.

    If you have any other ideas, I would appreciate them. I'll let you know Monday whether the longer path worked.
    Thanks again.

  7. #7
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disappearing Code (Office 2000)

    I tried the UNC path but my system would not accept this format. It insists on asking for a drive letter to start the address. The macro works at home and when I save the file as a doc on my C drive, it works.
    I attached it using Tools Options Templates and Add ins. The box is checked when I look at if from a File New and opening a document based on the template.

  8. #8
    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: Disappearing Code (Office 2000)

    > I attached it using Tools Options Templates and Add ins. The box is checked when I look at if from a File New and opening
    > a document based on the template.

    The "attached" template is the one that appears in the textbox at the top of that dialog, while the "add-ins" appear in the lower box with checkmarks (or without checkmarks, if they are not loaded). Try unloading the template as an add-in while making sure it is the attached template. Does that help at all?

Posting Permissions

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