Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2022, 06:03 AM
Bertus Bertus is offline Compatibility in docx, not in dotx Windows 10 Compatibility in docx, not in dotx Office 2016
Novice
Compatibility in docx, not in dotx
 
Join Date: Mar 2019
Posts: 8
Bertus is on a distinguished road
Default Compatibility in docx, not in dotx

Hi all,

in O365, I've made a small Excel-Word app for a customer. Installed it on customer's computer which still runs O/2016

Excel VBA opens Word, the adds a document based on a template I also made in 365.

Then my Excel code performs some actions on the document. On my sytem all works fine. On customer's not: one of the actions is to insert a BuildingBlock containing a table, then change that table's title in order to refer to it later on. This does not work on customer's system, throwing an error (just don't know the err.number)

If I open the document-template on customer's computer, it opens normally, and I could (manually) change the table's title. However if I add a new document based on that template, it opens in compatibility-mode, and the table's title property is greyed-out (in code it seems read-only.

I don't understand what is going on here. Any wise words as to solving the issue?
Reply With Quote
  #2  
Old 09-30-2022, 11:49 AM
spillerbd spillerbd is offline Compatibility in docx, not in dotx Windows 10 Compatibility in docx, not in dotx Office 2021
Competent Performer
 
Join Date: Jan 2016
Posts: 130
spillerbd is on a distinguished road
Default

Are the necessary VBA libraries available?
If you record the steps on the clients system, is the recorded VBA code the same/similiar?
Reply With Quote
  #3  
Old 10-01-2022, 01:36 AM
Guessed's Avatar
Guessed Guessed is offline Compatibility in docx, not in dotx Windows 10 Compatibility in docx, not in dotx Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Is the building block in the template you gave to the client or is somewhere on your machine (eg Normal.dotm or Building Blocks.dotx).

In older versions of Word - pre 2010 (and in some older compatibility modes) the Title property wasn't available. So you could ensure that the document is not in Compatibility Mode or more recent that 2007 before working with the table title.
Code:
ActiveDocument.SetCompatibilityMode wdWord2010
Selection.Tables(1).Title = "Hi Mum"  'this works
ActiveDocument.SetCompatibilityMode wdWord2007
Selection.Tables(1).Title = "Hi Mum"  'this throws 445 error
ActiveDocument.SetCompatibilityMode Application.Version 'set version to match Word version
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 10-01-2022, 03:05 AM
Bertus Bertus is offline Compatibility in docx, not in dotx Windows 10 Compatibility in docx, not in dotx Office 2021
Novice
Compatibility in docx, not in dotx
 
Join Date: Mar 2019
Posts: 8
Bertus is on a distinguished road
Default

Thank you both! I'll go over and try your suggestions on Monday. (No missing libraries btw)

Regards
Bart
Reply With Quote
  #5  
Old 10-01-2022, 07:00 AM
Charles Kenyon Charles Kenyon is offline Compatibility in docx, not in dotx Windows 11 Compatibility in docx, not in dotx Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by Bertus View Post
Hi all,

***

If I open the document-template on customer's computer, it opens normally, and I could (manually) change the table's title. However if I add a new document based on that template, it opens in compatibility-mode, and the table's title property is greyed-out (in code it seems read-only.

I don't understand what is going on here. Any wise words as to solving the issue?
If the new document based on the template opens in compatibility mode, the template, itself is likely in compatibility mode.
Reply With Quote
  #6  
Old 10-05-2022, 09:59 AM
Bertus Bertus is offline Compatibility in docx, not in dotx Windows 10 Compatibility in docx, not in dotx Office 2021
Novice
Compatibility in docx, not in dotx
 
Join Date: Mar 2019
Posts: 8
Bertus is on a distinguished road
Default

OK, I (well, with a lot of help) seem to have solved it, though it may not be an elegant solution:

changing a table's title works in O16, but as far as I can see not in O07. Word on user's computer says it's 2016 but if I ask for
Code:
ActiveDocument.CompatibilityMode
it returns 12 (weird or not?)

So I run
Code:
doc.SetCompatibilityMode 15
but for some reason that line resets all custom shape-names to their default, obviously causing problems referring to those in code later on (like setting a picture to a shape).
Editing the table's title at least works now.

Luckily I could reorder my subs to set CompatibilityMode to 15 after looping through all the shapes.

So, all in all, thank you guys for pointing me in this direction
Reply With Quote
  #7  
Old 10-12-2022, 04:34 PM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Compatibility in docx, not in dotx Windows 11 Compatibility in docx, not in dotx Office 2021
Moderator
 
Join Date: Aug 2011
Posts: 3,902
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

For future reference, Word VBA Help includes a description of the constants you can use with the SetCompatibilityMode method:

WdCompatibilityMode enumeration (Word) | Microsoft Learn
__________________
Stefan Blom
Microsoft Word MVP

Microsoft 365 apps for business
Windows 11 Professional
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compatibility in docx, not in dotx Word 2003 refuses to open DOCX, even with compatibility pack, after 2016 install ugcheleuce Word 2 01-30-2017 06:33 PM
Macro to save docx to doc that checks compatibility and converts content controls to static content. staicumihai Word VBA 4 10-12-2016 08:23 PM
Remove Compatibility Mode on DOCX files (batch) w64bit Word 17 02-01-2015 06:02 AM
compatibility mode VS saving to doc as opposed to docx airtas Word 7 05-30-2010 02:19 PM
Can I separate a word Doc (docx) from the template used to create it (dotx)? paulnevlud Word 2 12-14-2009 10:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:00 AM.


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