• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1263
  • Last Modified:

shared template macros not saving in .docm for some users

Hi experts.  I'm hoping someone can assist with this because I am stumped.

I've created a set of shared templates housed on a network.  The templates include a variety of automation and VBA code(macro enabled).  The users access these templates through a front-end menu system.  They choose a document they want to create and the system opens up a new document based on the appropriate template stored on the network.  If a user doesn't complete the document they are working on, they save it as a .docm file and can go back into it later to work on it.

For most users, this works without incident.  For some users, once they've save the document as a .docm file, when they go back into it, they lose their automation, but not all of it.  I've checked the VB coding and project info for both a working document and a non-functional document.  The references for the working document point to the shared template.  For the non-functional template the reference points to the normal template.

Can someone explain why this happens or how to correct?  Is it a setting on a user's individual machine or is it something to do with my coding?  Any assistance you can be is greatly appreciated as I've run up against a bit of a mental block on this one.  

Update:  

I've spoken directly with one of the users having the problem.  I will outline it below..  They create a new document using the template on the network.  All is fine and all functionality is there.  The save the document as a .docm file.  As long as they remain in the document all is fine.  They exit word and then go back into the document, they receive the following message:
File In Use
IMAGE ICAP.dotm is locked for editing by ...
Do you want to:
  Open a Read Only copy
  Create a local copy and merge your changes later
  Receive notification whent he original copy is available.

whatever option they pick, they lose the functionality from the template.  Specifically, the macros are gone and when you look at the VB editor, the reference to the templateproject from the network is not there.  It references the normal template instead.

Again, out of a couple hundred users this is only happening to a handful of people.  All are on windows XP.  There is another small group on Windows Vista that experience the same problem but I initially split that out thinking it was isolated to Vista.

Any guidance would be greatly appreciated!
Thank you
0
noclew
Asked:
noclew
  • 22
  • 20
2 Solutions
 
noclewAuthor Commented:
Sorry.  Can't upload docm files.
Thank you
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
I never think it's a good idea to have shared templates on a network.  They should be pushed to the user's hard drive and I think you would avoid this problem.  Is that a possibility?



0
 
noclewAuthor Commented:
Hi there!  Yes.  Infact, I've done a test with the user and that solves the sharing issue.  I'll re-work the front-end so that it checks for network connectivity and then pushes a new copy of the templates to the user.  Thanks for your suggestion!

2nd problem still remains.  Whenever he saves the document as a docm file, he loses the customized quick access toolbar that comes from the template.  This still happens although he uses a local template.  I think this has to be a localized problem because he's the only one it's happening to than I'm aware of.  Problem is he's in another city and I can't visualize what he may be doing wrong.  When he sends me the document and I open it, I see the customized quick access toolbar but he does not.  Any thoughts?
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
Joanne M. OrzechManager, Document Services CenterCommented:
Hmmm - so when he opens the template, goes to the Developer tab and selects Document Template, what is it pointing to?
0
 
noclewAuthor Commented:
Hi Jorzech.

Just want to make sure I'm asking him the right question.  When the document is first created (I use an add statement in VB), it correctly creates it using the template.  He can see and use the quick access toolbar.  He then saves it as a .docm file and exits Word.  When he re-opens the document the quick access toolbar is gone.

Prior to and after savings, the template it is pointing to is the same.  However, when I ask him to try and customize the quick access toolbar (add the icon back to it), he cannot.  He opens it up to customize it, goes to the macros and it is blank.

I am really puzzled but I'm thinking maybe something to do with his individual save settings or security settings.  Any thoughts would be greatly appreciated!
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Hmm - why is it being saved as a docm?  If it's attached to the template that contains the macros, it should not be necessary...
0
 
noclewAuthor Commented:
Totally agree.  He's save it both ways and neither way works.
0
 
noclewAuthor Commented:
JOrzech, could it be where I've placed the code within the template project? (Module, ThisDocument)
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
You could try moving all code to a new module within the template itself and see what happens.  I'll have to think about this one....
0
 
noclewAuthor Commented:
OK.  I'll try that with him tomorrow.  I'll post the results.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Thank you.
0
 
noclewAuthor Commented:
So sorry.  User wasn't in at the end of last week.  I will try and get them tomorrow.
0
 
noclewAuthor Commented:
JOrzech:

OK.  Here's the latest.  I moved all the code to a new module.  No change.  Once he saves the document as a .docx file, he loses the quick access toolbar when he goes back into the document.  In the references under that document, it references the Normal template instead of the customized template.  When I do the exact same thing at the exact same time with a document created from the exact same template, I do not lose the quick access toolbar and my reference is to the customized template.

If I click on tools and references, I have a reference to "template project".  He has a reference to "Normal" instead.

Any more thoughts?
0
 
noclewAuthor Commented:
Any more thoughts on this by anyone?
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Sorry noclew... I lost track of this.... when you open up one of these documents that loses its functionality -- go to Developer, Document Template, is the template IMAGE ICAP.dotm?
0
 
noclewAuthor Commented:
No.  It's Normal.dotm.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Well - that's your problem noclew. It has to be IMAGEICAP.DOTM.

So the users are going to File, New and selecting IMAGEICAP.DOTM and creating a document from that?

0
 
noclewAuthor Commented:
Hi there JOrzech!

That's what I thought too.  Problem is, it's not happening to everyone and I don't know how to change it for the ones it's happening to.  To answer your question, I am using a documents.add statement in VBA to create the new document for them using the IMAGEICAP.dotm file.  (Could be any other template in the directory) they choose as well.

Here's the code that creates the document.  I've tried to hard code the imageICAP.dotm one too and it doesn't make a difference.

I'm looking forward to your response...
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim ContentVariable
If UserForm1.ListBox1.Value <> "" Then
    ContentVariable = UserForm1.ListBox1.Value
    Documents.Add Template:=Environ$("USERPROFILE") & "\My Documents\D2I Templates\" & ContentVariable
    Exit Sub
Else
    MsgBox "You didn't choose anything"
End If
End Sub

Open in new window

0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Hmm - really strange -- can you try this?  I have no idea if it would make a difference but....
try adding newtemplate:=False

or add another line of code which attaches the template... similar to this:

    With ActiveDocument
        .UpdateStylesOnOpen = False
        .AttachedTemplate = _
            "C:\Documents and Settings\USER\Application Data\Microsoft\Templates\My Letterhead.dot"
        .XMLSchemaReferences.AutomaticValidation = True
        .XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
    End With



Documents.Add Template:=Options.DefaultFilePath(wdUserTemplatesPath) & "\Env.DOT", newtemplate:=False

Open in new window

0
 
noclewAuthor Commented:
Hi there.

First suggestion doesn't make a difference (newtemplate:= false).  2nd suggestion gives me a message that says "word cannot attach a document to a protected template".

Any more thoughts?
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
So it's protected on top of everything else? *laughing*  Why is it protected?
0
 
noclewAuthor Commented:
I know.  The project is protected because I don't want the users to be able to manipulate the code.  Is there another way?
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Are they smart enough to do that?

I would lock my code -- not the template.

Right-click the template in the VBE, go to Properties, Protection, and lock it for viewing... enter a password.
0
 
noclewAuthor Commented:
Hi JOrzech!  That's what I've done.  The protection on the rest of the document is there because it is a protected form they are completing.

Sadly yes.  They are smart enough to do that.  
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
So you have form fields in this template?

And is this still the case (you've pushed the templates to the user's hard drives right?):
Update:  

I've spoken directly with one of the users having the problem.  I will outline it below..  They create a new document using the template on the network.  All is fine and all functionality is there.  The save the document as a .docm file.  As long as they remain in the document all is fine.  They exit word and then go back into the document, they receive the following message:
File In Use
IMAGE ICAP.dotm is locked for editing by ...
Do you want to:
  Open a Read Only copy
  Create a local copy and merge your changes later
  Receive notification whent he original copy is available.

whatever option they pick, they lose the functionality from the template.  Specifically, the macros are gone and when you look at the VB editor, the reference to the templateproject from the network is not there.  It references the normal template instead.
0
 
noclewAuthor Commented:
Hi there.  You are correct.  I've pushed the templates directly to the hard drive.  It is running them from there.  This has resolved the locked for editing issue.  Problem still remains that the customized toolbar is gone and the reference reverts back to normal.dotm.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Any chance of uploading the template?
0
 
noclewAuthor Commented:
I could, problem is it's word 2007 template and I don't think this site lets me.  OK.  I've attached it by changing the file extension to docx.  You'll have to change it back to dotm before you open it or it won't work.  Let me know what you think.  I apologize if the code's a bit messy.
IMAGE-ICAP.docx
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
OK - sorry to be so thick - but exactly what functionality is missing?  What do your macros do?  It's password protected.
0
 
noclewAuthor Commented:
Hey there.  On the quick access toolbar, you will notice a "happy-face" icon.  That icon goes away as does the code.  The password I've put on it for you is "casemanagement".  Feel free to poke around.
0
 
noclewAuthor Commented:
FYI, that happy face icon invokes a macro that then leverages the Microsoft Office Document Image Writer and a print out command to save the document as a TIFF image to a specific location, building a specific file name.  From that location, the code then leverages the MODI object, to check to see if the document is actually a tiff, regardless of its extension or name based on the number of bits per pixel in the file.  If the bits per pixel is equal to 1, it moves the document to a shared network location for further processing by another program built to run through a 3270 emulation window.  If the document is not an actual TIFF document, it produces a message instructing the user in how to change the output format of the Image Writer from MDI to TIFF and then asks them to submit the document again.

The program that runs under 3270 continually scans that directory for files, grabs one when it finds it, parses the name into separate components that it uses for processing and then converts that document into an imaged document for the internal system with I believe is MODCA (IBM proprietary file format).

The code does a lot of other stuff to.  It adds or removes sections based on user input, changes the title of the document based on options chosen by a user and communicates with a 3270 emulator to gather specific information to autopopulate form fields.

Hope that is helpful.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Ok - :)  happy face... hee hee
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
I cannot make it disconnect from the original template... every time I save or save as, even as Word 2003 compatible, everything still works properly.  Have you watched the users do this?  Are you sure they're STARTING from the original template?  They're not re-using older forms?  

I guess I'm just thinking out loud.  But have you sat and watched this happen?  You know HOW they're saving it?  Is there Document Management in place?
0
 
noclewAuthor Commented:
See, this is my dilemma.  I can't see them as they are in different cities.  However, I just sent the one I've been dealing with a lot an unprotected version of the template and he can save it and then re-open it and the quick access toolbar is still there and the reference is correct.  From that, I'm assuming he's doing this correctly.

Problem is, with it unprotected, he can't tab from field to field and he can actually change content outside of what he should be able to change.  Any ideas on why for some the document needs to be unprotected to maintain the quick access toolbar and for others it doesn't matter?
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
I'm baffled... but I honestly think there's something else going on here... I just can't figure it out at this moment.  Their security settings are all the same?

0
 
Joanne M. OrzechManager, Document Services CenterCommented:
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Also - this is about Word 97.... but are all patches, updates,  etc. current on all computers?
http://support.microsoft.com/kb/173621
0
 
noclewAuthor Commented:
Hi there.

I'm not dealing with sharepoint.  I've thought of the security settings, but can't figure out what could possibly be different.  I can't seem to re-create it.  Again, this doesn't happen to all users, but if it's happening to someone, it's happening consistently.  I believe all computers are properly updated.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
The only thing I can suggested then is to search for all instances of normal.dot(m) etc. on the user hard drive and delete it...

I have also been unable to recreate the problem noclew.  Sorry... if I think of anything else, I'll be sure to let you know.

And all macro settings are like the attached image?
2007-Macro-Settings.gif
0
 
noclewAuthor Commented:
Hi there!
Very exciting.  One of the links you provided did help with a solution that seems to work....

I unprotect the template itself.  In the document_new section I add the attached code.

You cannot believe how frustrating this one has been and what a relief it is to have a solution!  Many, many thanks for this one!




Private Sub Document_New()
ActiveDocument.AttachedTemplate = ActiveDocument.AttachedTemplate
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True, Password:="Password"
End Sub

Open in new window

0
 
noclewAuthor Commented:
Again, thank you for your assistance.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Wow - who woulda thunk it was that easy!  Whew... glad it's resolved though..... sorry it took so darn long... but you really found it :)
0
 
TimLitleCommented:
Interestingly, I had this exact same problem where it seemed that the Template detached itself from a new Document based on that Template in Word 2007.  As you did, I added the second line:

Private Sub Document_New
ActiveDocument.AttachedTemplate = ActiveDocument.AttachedTemplate
etc.
End Sub

and it solved the problem!  Why such a statement would do anything is a real mystery to me.  Even more mysterious is that the problem stayed fixed even AFTER I removed the statement and tried again.  It even fixed OTHER Documents and Templates which I DIDN'T change.  It must have reset some switch deep in the bowels of Word 2007!

You saved me a whole lot if time!  Thanks.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 22
  • 20
Tackle projects and never again get stuck behind a technical roadblock.
Join Now