Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2023, 08:26 AM
Lydia90 Lydia90 is offline A Makro for automatically insert captions for specific letters Windows 10 A Makro for automatically insert captions for specific letters Office 2016
Novice
A Makro for automatically insert captions for specific letters
 
Join Date: Oct 2023
Posts: 6
Lydia90 is on a distinguished road
Default

hi vivka,
thanks for your help! that works so far, but: the numbers are just text. i cannot generated a Table of Figures from them / update them automatical. they are no captions.
Reply With Quote
  #2  
Old 10-18-2023, 10:36 AM
vivka vivka is offline A Makro for automatically insert captions for specific letters Windows 7 64bit A Makro for automatically insert captions for specific letters Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Lydia90, the following macro replaces all "Figure (your inputboxed txt)" with "Figure (sequential number)" and makes them captions in the selected range.
Code:
Sub Repl_Stri_W_Sequential_Nums()
'In slection, replace all instances of the inputboxed string
'with sequential numbers / add sequential numbers after each
'instance of the inputboxed string.

Dim myRng As range
Dim stri As String
Dim i As String

Application.ScreenUpdating = False

Set myRng = selection.range
    stri = InputBox("Enter the string to find")
    i = InputBox("Enter the number to start counting from")
    With myRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "Figure " & stri
        .Forward = True
        .Wrap = wdFindStop
        Do
            If .Execute And myRng.InRange(selection.range) Then
                i = i + 1
                myRng = "Figure " & i
                myRng.Style = wdStyleCaption
            Else: Exit Do
            End If
            myRng.Collapse wdCollapseEnd
        Loop
    End With
Application.ScreenUpdating = True
Set myRng = Nothing
End Sub
Reply With Quote
  #3  
Old 10-20-2023, 12:30 AM
Lydia90 Lydia90 is offline A Makro for automatically insert captions for specific letters Windows 10 A Makro for automatically insert captions for specific letters Office 2016
Novice
A Makro for automatically insert captions for specific letters
 
Join Date: Oct 2023
Posts: 6
Lydia90 is on a distinguished road
Default

hmm, no. nothing happens.
Reply With Quote
  #4  
Old 10-20-2023, 01:50 AM
vivka vivka is offline A Makro for automatically insert captions for specific letters Windows 7 64bit A Makro for automatically insert captions for specific letters Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Sorry, Lydia90! You are right. I've only styled the captions as captions but haven't made them actual captions.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
A Makro for automatically insert captions for specific letters VBA to insert captions without appending to existing captions Marrick13 Word VBA 17 03-21-2023 07:51 PM
A Makro for automatically insert captions for specific letters Insert Captions and Word Wrap TEAllred Word 1 11-22-2015 03:21 PM
A Makro for automatically insert captions for specific letters Captions: Changing captions in Appendix update all captions carnestw Word 3 10-27-2015 12:34 PM
A Makro for automatically insert captions for specific letters Captions automatically updating all previous entries jhats Word 1 07-29-2014 11:53 PM
A Makro for automatically insert captions for specific letters Captions mixing letters and numbers trew Word 7 11-21-2012 12:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:14 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