Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-26-2011, 07:49 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default Office 2010 Template Loses Its Filename On Open

After I create my template file I then open it and the filename is lost. The document opens up as "Document1".



This is no good as we want people to open the template and then save it using the original filename to a .docx extension.

Why does it do this and how do I fix it?

Thanks.
Reply With Quote
  #2  
Old 05-26-2011, 10:29 PM
macropod's Avatar
macropod macropod is offline Office 2010 Template Loses Its Filename On Open Windows 7 32bit Office 2010 Template Loses Its Filename On Open Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,490
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi MYGS,

That is how Word templates work.

If you add the following code to your template, it will prompt the user to save immediately a new file is created, using the template's name. From then on, the document can be edited & saved as per normal.
Code:
Private Sub Document_New()
With Dialogs(wdDialogFileSaveAs)
  .Name = Split(ThisDocument.AttachedTemplate.Name, ".")(0)
  .Show
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-30-2011, 06:34 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default Best way to organise templates & macros

Hi macropod,

Thanks for that.

I'm a noob when it comes to Word templates & VBA macro programming.

Can you please explain the best way to implement this code (as a macro I'm assuming), thanks.

Also I am using Private Sub rather than Private, what is the use of the Private identifier?
Reply With Quote
  #4  
Old 05-30-2011, 06:49 PM
macropod's Avatar
macropod macropod is offline Office 2010 Template Loses Its Filename On Open Windows 7 32bit Office 2010 Template Loses Its Filename On Open Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,490
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi MYGS,

For advice on installing macros, see: http://www.gmayor.com/installing_macro.htm
When doing the install, you'll need to open the template for editing, then be sure to add the code to the template's 'This Document' module.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-31-2011, 06:44 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default

Hi macropod,

Thanks for the info all working now! I also added a popup box prompting the user to add the project code to the filename prior to saving.

One issue I have now is that I have created a template on the server and other documents reference this template. Thats fine if you are connected to the server but if not the document takes forever to open in Word as it searches in vain for the template. Is there a way to quickly check for a server connection and if not present replace the attached template with local normal.dotx?

Im curious how people get around this, or do they simply not attach templates if the documents will be opened outside of the office environment?

Cheers.
Reply With Quote
  #6  
Old 05-31-2011, 07:27 PM
macropod's Avatar
macropod macropod is offline Office 2010 Template Loses Its Filename On Open Windows 7 32bit Office 2010 Template Loses Its Filename On Open Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,490
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi MYGS,

If that's happening with documents after they've been created & saved, that suggests you got something like the 'automatically update document Styles' option set (see under Devloper|Templates). Either that or you've got macro-enabled documents with code that points back to the template.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 05-31-2011, 08:00 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default

Hi macropod and thanks again for your help with this...

Yes you are correct, the template the document points to is macro-enabled. I found a macro to build the path for the file as Word does not have a native function for this without appending the filename too (we wanted to separate them out). I also force this to run on doc open using the AutoOpen macro.

So I wonder is it the macro or is it the fact that the template is inaccessible?

Auto-update doc styles is off.
Reply With Quote
  #8  
Old 05-31-2011, 08:38 PM
macropod's Avatar
macropod macropod is offline Office 2010 Template Loses Its Filename On Open Windows 7 32bit Office 2010 Template Loses Its Filename On Open Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,490
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi MYGS,

It doesn't matter that the template is macro-enabled (that was necessary for the Document_New macro I gave you to work). What matters is whether the created document has a macro that points back to the template. Presumably, the culprit is in your AutoOpen macro. From what I understand of the situation, once the newly-created file has been saved, you shouldn't need that macro. In which case, the relevant code should probably be incorporated into the Document_New macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 05-31-2011, 09:25 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default

Hi again macropod,

Everything works fine if I use a local template.

But as soon as I use a network template where the connection to the network is severed that's when the document takes forever to load presumably as Word is doing a network search. This is similar to when you click on a mapped drive in Explorer where you've lost the network connection and Explorer does this big search phase holding up the works for that instance of Explorer.

I could see a potential solution where the macro asked "is network present?" if not then use local normal.dot template if yes then use attached template. I'm guessing that's a pretty tall order though. I think MS should reduce the search time, no wonder many avoid using attached templates! Im beginning to wonder if I should do the same and go back to .dotx templates for each individual project doc.
-----------------------------------------------------------------------------
On another note. I decided to create a master styles template and then create "template" docs attached to that template (.docx). So if we wanted to update the styles like fonts, colours, etc, we could without having to update each document "template" individually. The reason I did this is because you can't attach a template to a template (.dotx). So there's no way to manage the styles of templates at a global level. I looked at the 'global templates/addins' but its even worse there as you need to have a local copy present for them to work.

I'm certainly wanting to find a good solution to this before I create any more project templates as don't want to have to redo them.
Reply With Quote
  #10  
Old 05-31-2011, 10:44 PM
macropod's Avatar
macropod macropod is offline Office 2010 Template Loses Its Filename On Open Windows 7 32bit Office 2010 Template Loses Its Filename On Open Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,490
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi MYGS,

You haven't addressed the issue I raised about what's in the AutoOpen macro. Is that in the saved document? If so, does it call the template and, if so, why?

You might also find some useful pointers here: http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 06-01-2011 at 12:40 AM.
Reply With Quote
  #11  
Old 05-31-2011, 11:44 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default

Hi macropod,

The AutoOpen macro does the following:
- Grabs the path of the active document and places it in a DocProperty variable
- Updates all fields in the document
- Displays popup message box

This macro named "StartUp" is located in the template let's call it TEMPLATE.DOTM and that template lives on a network drive. All runs fine when you're at the office but work from home or onsite and you get the big delay and of course nothing updates. I just wanted one location for any globally used macros. The reason we wanted path in the doc as it can be frustrating when you have a lot of docs and folders and not know where they are.

I guess the obvious solution is to dice the whole global template concept and go back to creating each type of project doc as a .DOTX template file that includes all the macros. I just felt that if I wanted to include a macro feature I would then have to replicate it manually across a whole bunch of docs and that's a real pain.

Any suggestions?
Reply With Quote
  #12  
Old 06-01-2011, 12:48 AM
macropod's Avatar
macropod macropod is offline Office 2010 Template Loses Its Filename On Open Windows 7 32bit Office 2010 Template Loses Its Filename On Open Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,490
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi MYGS,

I take it, then that the AutoOpen macro is in the saved document. This is the first time you've mentioned the 'StartUp' macro. If that's being called by the AutoOpen macro, then obviously that call is where the issue lies. You might get a better result if you test whether the path to the network folder exists (eg using Dir) before trying to access the template there.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 06-01-2011, 11:19 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default

HI macropod,

Have you got an example of how to implement the 'Dir' command for this purpose?
Thanks.
Reply With Quote
  #14  
Old 06-01-2011, 11:45 PM
macropod's Avatar
macropod macropod is offline Office 2010 Template Loses Its Filename On Open Windows 7 32bit Office 2010 Template Loses Its Filename On Open Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,490
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi MYGS,

Something along the lines of:
Code:
If Dir("K:\*.*") = "" Then
  MsgBox "Network Not Found", vbOKOnly & vbExclamation
Else
' Your template-related code goes here
End If
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 06-02-2011, 09:44 PM
MYGS MYGS is offline Office 2010 Template Loses Its Filename On Open Windows 7 64bit Office 2010 Template Loses Its Filename On Open Office 2010 32bit
Novice
Office 2010 Template Loses Its Filename On Open
 
Join Date: May 2011
Posts: 17
MYGS is on a distinguished road
Default

Hi macropod,

Thanks for that, it works in principle, but I'm away from the office today so will have to test next week when I get back. I think this should do the trick though.

What would I do without gurus like you? lol

Thanks again you've really been an awesome help...
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing word/excel from trying to open external template locations Perhill Office 0 03-02-2011 04:44 AM
Office 2010 Template Loses Its Filename On Open From Office '03 to '10 - where is the Excel filename ??? TL86 Excel 4 02-21-2011 08:08 AM
Upgraded from Office 2007 to Office 2010, now can't open Outlook MDuff Outlook 2 01-27-2011 01:06 PM
License Office Standard 2010 and Home and business 2010 papypaul2 Office 0 11-05-2010 08:55 AM
Macro to open template not working Brandi Mail Merge 2 06-24-2010 09:29 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 04:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft