Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2014, 08:36 AM
ilsamaria ilsamaria is offline How to fix the caption separators with VBA word Windows 7 64bit How to fix the caption separators with VBA word Office 2010 64bit
Novice
How to fix the caption separators with VBA word
 
Join Date: Apr 2014
Posts: 7
ilsamaria is on a distinguished road
Default How to fix the caption separators with VBA word

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?
Reply With Quote
  #2  
Old 04-07-2014, 09:23 PM
macropod's Avatar
macropod macropod is offline How to fix the caption separators with VBA word Windows 7 32bit How to fix the caption separators with VBA word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try adding:
ActiveDocument.Fields.Update
after your code.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-28-2014, 12:22 AM
ilsamaria ilsamaria is offline How to fix the caption separators with VBA word Windows 7 64bit How to fix the caption separators with VBA word Office 2010 64bit
Novice
How to fix the caption separators with VBA word
 
Join Date: Apr 2014
Posts: 7
ilsamaria is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 04-28-2014, 01:02 AM
macropod's Avatar
macropod macropod is offline How to fix the caption separators with VBA word Windows 7 32bit How to fix the caption separators with VBA word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 04-28-2014, 01:09 AM
ilsamaria ilsamaria is offline How to fix the caption separators with VBA word Windows 7 64bit How to fix the caption separators with VBA word Office 2010 64bit
Novice
How to fix the caption separators with VBA word
 
Join Date: Apr 2014
Posts: 7
ilsamaria is on a distinguished road
Default

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
Attached Files
File Type: docx Example.docx (52.5 KB, 10 views)
Reply With Quote
  #6  
Old 04-28-2014, 01:15 AM
macropod's Avatar
macropod macropod is offline How to fix the caption separators with VBA word Windows 7 32bit How to fix the caption separators with VBA word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
PS: I've deleted the new thread you've just started on the same topic. Please don't create multiple threads for a single issue!
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 04-28-2014, 01:18 AM
ilsamaria ilsamaria is offline How to fix the caption separators with VBA word Windows 7 64bit How to fix the caption separators with VBA word Office 2010 64bit
Novice
How to fix the caption separators with VBA word
 
Join Date: Apr 2014
Posts: 7
ilsamaria is on a distinguished road
Default

Oh yes, I see,
But it doesnt with this document?
Attached Files
File Type: docx Headings.docx (65.8 KB, 12 views)
Reply With Quote
  #8  
Old 04-28-2014, 01:19 AM
macropod's Avatar
macropod macropod is offline How to fix the caption separators with VBA word Windows 7 32bit How to fix the caption separators with VBA word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #9  
Old 04-28-2014, 01:21 AM
ilsamaria ilsamaria is offline How to fix the caption separators with VBA word Windows 7 64bit How to fix the caption separators with VBA word Office 2010 64bit
Novice
How to fix the caption separators with VBA word
 
Join Date: Apr 2014
Posts: 7
ilsamaria is on a distinguished road
Default

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)
Reply With Quote
  #10  
Old 04-28-2014, 01:25 AM
macropod's Avatar
macropod macropod is offline How to fix the caption separators with VBA word Windows 7 32bit How to fix the caption separators with VBA word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #11  
Old 04-28-2014, 01:40 AM
ilsamaria ilsamaria is offline How to fix the caption separators with VBA word Windows 7 64bit How to fix the caption separators with VBA word Office 2010 64bit
Novice
How to fix the caption separators with VBA word
 
Join Date: Apr 2014
Posts: 7
ilsamaria is on a distinguished road
Default

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?
Reply With Quote
  #12  
Old 04-28-2014, 01:49 AM
macropod's Avatar
macropod macropod is offline How to fix the caption separators with VBA word Windows 7 32bit How to fix the caption separators with VBA word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by ilsamaria View Post
If you close the document en open it again, it doesn't work anymore.
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]
Reply With Quote
  #13  
Old 04-28-2014, 02:21 AM
ilsamaria ilsamaria is offline How to fix the caption separators with VBA word Windows 7 64bit How to fix the caption separators with VBA word Office 2010 64bit
Novice
How to fix the caption separators with VBA word
 
Join Date: Apr 2014
Posts: 7
ilsamaria is on a distinguished road
Default

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?
Reply With Quote
  #14  
Old 04-28-2014, 04:01 AM
macropod's Avatar
macropod macropod is offline How to fix the caption separators with VBA word Windows 7 32bit How to fix the caption separators with VBA word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by ilsamaria View Post
But if you save the document (with wrong caption) and than open it again, it wont work anymore.

Do you get wat I mean?
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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fix the caption separators with VBA word Word 2013: Separating text in a caption 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
How to fix the caption separators with VBA word Word 2007 Caption/Cross-reference problem yeatsbaby Word 9 04-10-2012 03:16 PM
MS Word figure caption numbering skaboy607 Word 3 03-21-2012 02:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:54 AM.


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