![]() |
|
#1
|
|||
|
|||
![]()
Hi,
I'm currently making a VBA macro which sets the whole word document in a correct style. I only have problems fixing the separators of the captions. The captions of the tables and the figures allready exist, I just need a macro which corrects all the captions to separators with periods. I know it has something to do with: With CaptionLabels("Figure") .separator = wdSeparatorPeriod .includeChapterNumber = true End with But how to acitivate this for all the captions? |
#2
|
||||
|
||||
![]()
Try adding:
ActiveDocument.Fields.Update after your code.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Hi again,
it still doesnt work, tried a bunch of things, but the hyphen in the captions won't change to periods.. Thanks in advance |
#4
|
||||
|
||||
![]()
Can you attach a document to a post with some representative captions (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Here an example document.
I need the vba to change all the captions with the correct separators. On the second page you find my macro |
#6
|
||||
|
||||
![]()
Your original code works fine for me as part of a complete macro:
Code:
Sub Demo() With CaptionLabels("Figure") .Separator = wdSeparatorPeriod .IncludeChapterNumber = True End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
![]()
Oh yes, I see,
But it doesnt with this document? |
#8
|
||||
|
||||
![]()
I ran the code on your previous attachment and it was updated. The latest one has no captions to update...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
![]()
Yes, created the example for the forum, but saw when it runned it worked for me as well.
But it doesnt run on the other (or any other document) |
#10
|
||||
|
||||
![]()
Your other document has no captions! Furthermore, if you add one, it displays as Figure 1.1. Since you have no captions, but any that you add are already in the correct format, that's why the macro won't do anything.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
![]()
I've been playing around with it a bit, and I know the problem
If you close the document en open it again, it doesn't work anymore. On any new document where it is set as a caption it does. What does it change to the caption? |
#12
|
||||
|
||||
![]()
Did you save the changes? unless you have some other macro etc that runs at open, there is no other reason I can see why the changes would not remain. Note that making these changes does not affect new documents.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
![]()
Yes but it's a macro which must fix old documents.
So if the caption is inserted new in the document, it works, even if its inserted with a hyphen. But if you save the document (with wrong caption) and than open it again, it wont work anymore. Do you get wat I mean? |
#14
|
||||
|
||||
![]()
No, I don't get that. Can you attach a document on which you say it won't work anymore?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
al.25 | Word | 3 | 04-01-2014 03:04 PM |
Word 2011 MAC - caption numbering problem | aureiphi | Word | 9 | 07-22-2013 02:47 AM |
everything before caption in word is copied when referenced | rickez3 | Word | 1 | 01-31-2013 11:15 PM |
![]() |
yeatsbaby | Word | 9 | 04-10-2012 03:16 PM |
MS Word figure caption numbering | skaboy607 | Word | 3 | 03-21-2012 02:31 PM |