![]() |
|
#4
|
||||
|
||||
|
Quote:
You can call the function where you want to use the caption in your larger macro e.g. Code:
Sub TestCaption()
Const fName1 As String = "1 Dog is brown. Dog is big.jpg"
Const fName2 As String = "1.2 Cat is black. Cat is little.jpg"
Const fName3 As String = "2 Pencil is a yellow. Pencils are great.jpg"
Dim sCaption As String
sCaption = GetCaption(fName1)
MsgBox sCaption
sCaption = GetCaption(fName2)
MsgBox sCaption
sCaption = GetCaption(fName3)
MsgBox sCaption
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 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to uninstall portions of Office Pro 2016 | Moondoggy | Office | 1 | 07-10-2020 04:10 AM |
| filename field not displaying correct filename when that name starts with # | plrsmith | Word | 1 | 07-06-2018 03:10 AM |
Filename
|
UnlimitedPower | Word VBA | 1 | 08-19-2016 12:22 AM |
| Showing or hiding portions of contract based on selected services. | BlackrazorNZ | Word | 1 | 05-30-2014 05:43 AM |
| Error! Filename not Specified | mark.lacey | Outlook | 0 | 10-12-2011 03:02 AM |