Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub InsertIMG()
- 'replace image address to IMG HTML tag
- 'data format:
- '[http://example.com/images/example.jpg]
- 'Result:
- '<img src="http://example.com/images/example.jpg">
- 'Select text & run macros
- Dim IMGTemplate As String
- Dim IMGAddr As String
- Dim IMGOut As String
- Dim IMGStart As Integer
- Dim IMGEnd As Integer
- IMGTemplate = "<img src=""%addr%"">"
- IMGStart = InStr(1, Selection.Text, "[")
- IMGEnd = InStr(1, Selection.Text, "]")
- If (IMGStart = 0) Or (IMGEnd = 0) Then
- MsgBox "No Link :("
- Exit Sub
- End If
- IMGAddr = Trim$(Mid$(Selection.Text, IMGStart + 1, IMGEnd - IMGStart - 1))
- IMGOut = Replace(IMGTemplate, "%addr%", IMGAddr)
- Selection.Text = IMGOut
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement