Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2022, 08:44 PM
brownees brownees is offline Insert Caption no longer works Windows 10 Insert Caption no longer works Office 2021
Novice
Insert Caption no longer works
 
Join Date: May 2022
Location: Tauranga, New Zealand
Posts: 7
brownees is on a distinguished road
Post Insert Caption no longer works

For some reason my macros disappeared in the last week or so from my Normal template. I'm blaming a MS update but who knows? I got lucky and was able to retrieve my photo manipulating macro text from an email, but unfortunately it no longer works, details follow:



I have been happily selecting a photo and using the following macro in Word to resize, add a border and add a sequential caption starter in the form "Photo xx: ". It now fails with the runtime error 4198 when inserting the caption.

I have tried to insert the caption manually (References/Insert Caption) and see there is no Photo option available in the Label dropdown menu (see attached screenshot).

Thanks in advance to any welcome assistance with this.


Code:
Sub PhotoResize()
'
' PhotoResize Macro
'
    With Selection.InlineShapes(1)
        With .Borders(wdBorderLeft)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth050pt
            .Color = wdColorAutomatic
        End With
        With .Borders(wdBorderRight)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth050pt
            .Color = wdColorAutomatic
        End With
        With .Borders(wdBorderTop)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth050pt
            .Color = wdColorAutomatic
        End With
        With .Borders(wdBorderBottom)
            .LineStyle = wdLineStyleSingle
            .LineWidth = wdLineWidth050pt
            .Color = wdColorAutomatic
        End With
        .Borders.Shadow = False
    End With
    With Options
        .DefaultBorderLineStyle = wdLineStyleSingle
        .DefaultBorderLineWidth = wdLineWidth050pt
        .DefaultBorderColor = wdColorAutomatic
    End With
    
    'Resize photo
    Selection.InlineShapes(1).Height = 283.45
    Selection.InlineShapes(1).Width = 378.15
    
    'Remove space below photo
    Selection.ParagraphFormat.SpaceAfter = 0
    
     'Insert caption
    Selection.InsertCaption Label:="Photo", TitleAutoText:="InsertCaption1", _
        Title:="", Position:=wdCaptionPositionBelow, ExcludeLabel:=0
    
    'Turn off bold
    Selection.MoveLeft Unit:=wdCharacter, Count:=8, Extend:=wdExtend
    Selection.Font.Bold = wdToggle
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=": "
        
    'Carriage return
    Selection.TypeParagraph
    
End Sub
Attached Images
File Type: png z.png (50.5 KB, 14 views)

Last edited by macropod; 05-05-2022 at 06:18 AM. Reason: Added code tags
Reply With Quote
  #2  
Old 05-05-2022, 06:17 AM
macropod's Avatar
macropod macropod is offline Insert Caption no longer works Windows 10 Insert Caption no longer works Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

For your code to work, you need to use the 'New Label' option on the Caption dialogue to add a label named 'Photo'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-08-2022, 05:41 PM
brownees brownees is offline Insert Caption no longer works Windows 10 Insert Caption no longer works Office 2021
Novice
Insert Caption no longer works
 
Join Date: May 2022
Location: Tauranga, New Zealand
Posts: 7
brownees is on a distinguished road
Default

Problem solved

Last edited by brownees; 05-08-2022 at 05:58 PM. Reason: Problem solved
Reply With Quote
  #4  
Old 05-08-2022, 05:55 PM
macropod's Avatar
macropod macropod is offline Insert Caption no longer works Windows 10 Insert Caption no longer works Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

While the code image you've posted looks very colourful, you don't say where the syntax error occurs. That said, given the amount of red, I'd suspect you have some invalid characters (e.g. non-breaking spaces) there.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Caption no longer works Hyperlink to heading no longer works after edit alang12a Word 6 02-26-2022 06:50 AM
Macro no longer works Halda Word VBA 7 03-10-2021 12:31 PM
Mailsound and desktop notifications no longer works Merlin Outlook 0 01-23-2018 01:06 AM
Insert Caption no longer works Help with a formula which no longer works. Silkwood Excel 2 03-21-2017 02:25 PM
2007 office key no longer works millertime Office 6 02-19-2012 07:50 PM

Other Forums: Access Forums

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


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