Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-04-2012, 05:08 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

That makes it a whole lot more complicated:


Code:
Sub CaptionBold()
Application.ScreenUpdating = False
Dim Shp As Shape
With ActiveDocument
  On Error Resume Next
  .Styles.Add "CaptionLabel", wdStyleTypeCharacter
  On Error GoTo 0
  .Styles("CaptionLabel").Font.Bold = True
  .Styles("Caption").Font.Bold = False
  Call Processor(.Range)
  For Each Shp In .Shapes
    If Not Shp.TextFrame Is Nothing Then
      With Shp.TextFrame
        .TextRange.InsertAfter vbCr
        .TextRange.Paragraphs.Last.Style = "Normal"
        Call Processor(.TextRange)
        .TextRange.Characters.Last.Delete
      End With
    End If
  Next
End With
Application.ScreenUpdating = True
End Sub
 
Sub Processor(Rng As Range)
With Rng
  With .Find
    .ClearFormatting
    .Text = ""
    .Style = "Caption"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  Do While .Find.Found
    With .Paragraphs.Last.Range.Duplicate
      .End = .Start + Len(Split(.Text, " ")(0)) + 1
      .MoveEndUntil " ", wdForward
      .Style = "CaptionLabel"
    End With
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 11-04-2012, 01:37 PM
Tari Tari is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Nov 2012
Posts: 2
Tari is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
That makes it a whole lot more complicated:
Code:
Sub CaptionBold()
...
End Sub
Run-time error '5917'
this object does not support attached text.

Last edited by macropod; 11-04-2012 at 01:51 PM. Reason: Deleted unnecessary replicated content
Reply With Quote
  #3  
Old 11-04-2012, 01:53 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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 didn't get that error in my testing.

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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 11-15-2013, 04:03 PM
rjgs rjgs is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Nov 2013
Posts: 3
rjgs is on a distinguished road
Default

I have solved this by inserting cross reference to the table or figure after I have formatted the figure or table label. This ensures that the references is then not in bold.
Reply With Quote
  #5  
Old 11-15-2013, 04:04 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

The formatting depends on the Style definitions - there is nothing in the code to make anything bold. Similarly, the changes to the Style definitions do not of themselves cause cross-references to them to change format.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 12-13-2014, 08:19 AM
luoiliembac luoiliembac is offline Windows 8 Office 2010 64bit
Novice
 
Join Date: Dec 2014
Posts: 2
luoiliembac is on a distinguished road
Default

Oh my god, I checked again, it worked ^^.
Thank all of you ^^, so helpful topic.
Reply With Quote
  #7  
Old 02-26-2017, 07:36 AM
Witemon Witemon is offline Windows 10 Office 2013
Novice
 
Join Date: Feb 2017
Posts: 1
Witemon is on a distinguished road
Default How to create this macro?

Hi,
If I didn't have Paul's code, how would I create such macro? How to make the macro apply the change automatically to every caption label?
Reply With Quote
  #8  
Old 02-27-2017, 04:46 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Why do you want to re-invent the wheel?

As has already been discussed, the changes won't happen automatically - you have to run the macro and it won't do that of its own accord.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 03-14-2017, 03:30 PM
Jamal NUMAN Jamal NUMAN is offline Windows 7 64bit Office 2010 64bit
Expert
 
Join Date: Nov 2010
Posts: 615
Jamal NUMAN is on a distinguished road
Question

Quote:
Originally Posted by macropod View Post
Why do you want to re-invent the wheel?

As has already been discussed, the changes won't happen automatically - you have to run the macro and it won't do that of its own accord.
We hope that such issues to be resolved and gets out-of-the-box in the future releases
Reply With Quote
  #10  
Old 03-14-2017, 06:32 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

That is unlikely to happen unless Microsoft is persuaded there is a significant business case for it. If you don't like the way something works, or you'd like to see some new functionality added, you could make a suggestion for a change at http://word.uservoice.com/.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Matching text style to drawing object style notarichman PowerPoint 0 03-07-2011 11:34 AM
One line of text - two formats? judicial85 Word 4 02-18-2011 04:24 AM
Formatting of TOC's generated based on the "Caption" style JustinWord1000 Word 1 02-15-2011 03:13 PM
unwanted text in a label J J J J Word 0 11-22-2010 11:04 AM
Custom caption label annoyance zac Word 1 08-29-2010 09:56 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:16 PM.


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