#1
|
|||
|
|||
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? |
#2
|
|||
|
|||
Are the necessary VBA libraries available?
If you record the steps on the clients system, is the recorded VBA code the same/similiar? |
#3
|
||||
|
||||
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 |
#4
|
|||
|
|||
Thank you both! I'll go over and try your suggestions on Monday. (No missing libraries btw)
Regards Bart |
#5
|
|||
|
|||
Quote:
|
#6
|
|||
|
|||
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 So I run Code:
doc.SetCompatibilityMode 15 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 |
#7
|
||||
|
||||
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 |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |