I recorded a macro for a link that contains “https://www.” at the beginning of it, and it works great.
I want to create one macro, regardless of whether it begins with
which pastes the link in this specific format. I am coming from Python and am unfamiliar with VBA. In python, I would do something like this:
if "http://www." in mylink: replace("http://www.", "")
for each of the aforementioned bullets.
How would I do something similar in VBA?
Here’s my current macro that removes “https://www.” and formats the link as desired (underlined, size 10, in parentheses)
`Sub piclink() ' ' piclink Macro ' ' Application.Run MacroName:="Normal.NewMacros.PS" Selection.HomeKey Unit:=wdLine Selection.MoveRight Unit:=wdCharacter, Count:=12, Extend:=wdExtend Selection.TypeBackspace Selection.EndKey Unit:=wdLine, Extend:=wdExtend If Selection.Font.Underline = wdUnderlineNone Then Selection.Font.Underline = wdUnderlineSingle Else Selection.Font.Underline = wdUnderlineNone End If Selection.HomeKey Unit:=wdLine Selection.TypeText Text:="(" Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine Selection.TypeText Text:=")" Selection.HomeKey Unit:=wdLine, Extend:=wdExtend Selection.Font.Shrink Selection.Font.Shrink Selection.Font.Shrink End Sub`
I will note that “Application.Run MacroName:=”Normal.NewMacros.PS”” is a simple copy and paste function.