PDA

View Full Version : Problems with older template opening Office 2007 documents.



AndyFMR
10-04-2011, 08:30 AM
I have a word template (developed with Offfice 2003) that is now running on systems that have Office 2007 installed. This template used to run correctly when the systems had Office 2003 installed. Now when users attempt to open existing documents (created with the template) they are getting errors opening the document. I have determined that the ActiveDocument is not set for when Document_Open is called. The Document_Open method attempts to access ActiveDocument and the user is getting an error "Command is not available because no document is open".

My first question is, does anyone know why the ActiveDocument would be null (or not accessible)? My original though was that the document is being downloaded from a server and possibly the document has not been fully download when Document_Open is called.

I change the code to not access the ActiveDocument in the Document_Open method and that seemed to fix the problem on my dev. system, however when I moved the template to a test system and opened existing documents using the template, it is now getting other errors. The errors seem to be fairly random like the wrong methods are being called (I've set breakpoints in the code to verify this). I am fairly new to VBA programming so I'm not sure if I'm missing something basic or if these problems are related to switching from Office 2003 to 2007. Does anyone know why a template would work correctly on one system and when moved to another system it fails?

Any help would be appreciated.

Thanks

Frosty
10-05-2011, 09:23 AM
This is a pretty broad question. In short-- there are a *lot* of reasons things can fail between versions, depending on how well you've coded something.

However, in most cases, a 2003 template should work basically the same way in 2007, although there will be User Interface type issues (menu items/custom toolbars will appear in the Addins tab, heavily customized UI stuff may break).

Errors probably aren't random, and saying they seem to be doesn't really advance the troubleshooting.

If you've already troubleshot the various environment issues (i.e., are you on the same OS? Same network architecture, etc?)... then it would probably behoove you to simplify everything that is going on, and simply post a sample template of the architecture you're having a problem with.

I can't really imagine a scenario where the Document_Open method in the ThisDocument class module would be triggered, and yet no ActiveDocument would be available... unless you're manually calling the Document_Open (your "ActiveDocument is not set" statement concerns me-- ActiveDocument is not something you set).

In short-- it's hard to comment too much with no code and an incomplete picture of what you're doing.

I'm guessing you're missing something basic. I've successfully used very complex templates directly from 2003 to 2007 and 2010.

AndyFMR
10-13-2011, 01:19 PM
Hi Frosty,

Thank you for the response.

The problem I was seeing seems to be related to the template file being stored in more than one location. When a document that was created with the template was loaded it was attaching to the tempalte saved on a network drive (I'm not sure how it is doing this). It was then attaching to the same template saved on the users local drive.

It seems that this dual location is causing problems with Office 2007 but was not with Office XP.

After removing the template from the network drive the documents now open without errors.

Frosty
10-13-2011, 04:10 PM
Word will do some "best efforts" when looking for an Attached Template if it fails to find it on the first try in (if I recall correctly) something along the following lines:

1. Attached Template Property (ex: C:\MyTemplates\MyTemplate.dot)
but if it doesn't find it there, it will look for "MyTemplate.dot" existing in..
2. Usergroup file location
3. Workgroup file location
4. The analogs within the profile (I think).

Bottom line: the versions may have changed how hard Word looks when it doesn't immediately find the template in the location specified when the document was last saved.

I haven't tested the specifics between the versions, but maybe knowing that Word looks in more than just the Tools > Templates And Addins > Attached Template path in order to access the attached template, will help understand what might have been going on.