View Single Post
 
Old 02-08-2024, 02:51 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Your code is using a string variable called MyText so we can use a string function to replace a string with another string inside that variable
Code:
Sub sss()
  Dim MyText As String
  MyText = Selection.Text
  Selection.Style = ActiveDocument.Styles("MyStyle")
  Debug.Print MyText
  MyText = Replace(MyText, """", "/""")
  Debug.Print MyText
  Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & MyText & """ \l 3 ", PreserveFormatting:=False
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote