View Single Post
 
Old 02-03-2022, 10:05 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following should work
Code:
Sub Test()
    MsgBox GetCaption(ActiveDocument.Name)
End Sub

Function GetCaption(sName As String)
Dim sCaption As String
Dim iPos As Integer
    If IsNumeric(Left(sName, 1)) = True Then
        iPos = InStr(1, sName, " ")
        sCaption = Mid(sName, iPos + 1)
    Else
        sCaption = sName
    End If
    sCaption = Left(sCaption, InStrRev(sCaption, "."))
    GetCaption = sCaption
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote