#1
|
|||
|
|||
Inserted AutoText table incorrectly formatted - unless macro paused!
Hi,
I have some code that worked fine in Word 2003 but is going wrong in 2010. It just adds an autotext entry into the document: a single cell table. This table has been formatted to have: PreferredWidthType = wdPreferredWidthPercent and PreferredWidth = 100 When VBA is used to insert this autotext table inside another table (which happens all the time as the document is formatted as a two-column table), the preferred width type reverts to wdPreferredWidthPoints and becomes too wide. The strange thing is that if I put a breakpoint or a Stop ANYWHERE in this code and then run and resume the macro, all is well. Is this some kind of refresh issue? I've tried putting a Sleep delay AFTER the line that inserts the autotext into the code but curiously the table only gets inserted after the delay. I've tried also putting code that explicitly changes the preferred width options to percent/100 after the Sleep delay and this is ignored. Any ideas gratefully received... |
#2
|
|||
|
|||
I think it might work if you include the paragraph mark immediately after the one-cell table when you create the AutoText entry for it. (It may be necessary to format both the table and the cell with a preferred width of 100%.) But you will then also have to delete that paragraph mark ever time after inserting it in a document.
|
#3
|
|||
|
|||
Thanks for the tip but unfortunately it still doesn't work. It seems to be more fundamental to the way the VBA is running. If I put a break point after the AutoText insertion line and just resume the macro after it stops, the table inserts with the correct preferred width settings. Similarly if I put some code that intentionally errors, e.g.
For lngCtr = 1 To 10000000000# Next (this causes an overflow error) if I then click out of the error message, all is well. Very strange |
#4
|
|||
|
|||
With my Word 2013, I never get an error message (or thrown into the VBA Editor without an error message) when running the macro to insert an AutoText entry consisting of a one cell table, so there is no reason for me to put in a break point or delay.
I have a couple of other thoughts though. Maybe the cached copy of your macro template has become corrupted and needs to be re-cached. In Word 2013, the preferred code is to use .BuildingBlockEntries property instead of the .AutoTextEntries property ... so if your macro uses .AutoTextEntries you might want to see if .BuildingBlockEntries works better ... I doubt it will though, since .AutoTextEntries works equally well on my Word 2013. |
#5
|
||||
|
||||
Hi Smallweed,
It would be helpful if you could attach a document to a post containing both the autocorrect entry the table you're trying to insert it into and the code you're using. You can do this via the paperclip symbol on the 'Go Advanced' tab.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Picture inserted in table not visible - Again | peytontodd | Word | 5 | 11-12-2013 07:04 AM |
Picture inserted in cell of table is not visible | peytontodd | Word | 1 | 12-07-2012 08:36 PM |
Numbered List paragraph style prints out incorrectly when converted to PDF - Help! | kimrussell68 | Word | 0 | 02-02-2010 07:58 AM |
Maintaining AUtotext Entries from an external table. | kelzud | Word Tables | 0 | 07-28-2009 01:31 PM |
Insert formatted table into word (mail merge) | manojbmsce | Mail Merge | 0 | 09-25-2008 02:25 AM |