Attached code adjusted slightly to also file links.
Public Function convertSingleBracket (txt As String) As String
' special single-bracket cases
' [http://example.com linkname] should be converted to a link
' [file:filename linkname] is a link reference to an attached file
' [file:filename_id!!filename.ext linkname] is a link reference to file in a resource document
' [image:filename left|right] should become an <img> reference
' [image:filename_id!!filename.ext left|right] should become an <img> tag to a file resource within the database
'** [wiki:WikiWord alternate text] is a WikiWord link with alternate text
Dim leftText As String
Dim rightText As String
Dim newText As String
Dim fileWebPath As Variant
Dim intLoc1, intLoc2 As Integer
Dim fileID, fileName As String
<br/>
' remove any brackets that may have snuck in there
newText = Trim(Replace(txt, "[", ""))
' get rid of any HTML tags we might have inadvertantly inserted
newText = ReplaceRangeEnds(newText, "<", ">", "", "", "*", True)
'This !! syntax is used for entering image resources (images contained in resource documents)
'If present we need to extract specific information from the string, see above for syntax
intLoc1 = Instr(newText, "!!")
<br/>
If intLoc1 <> 0 And (Instr(newText, "image:")=1 Or Instr(newText, "file:")=1) Then
'Get the filename id (eg TheFriendlyName) and the specified filename (eg AttachedImage.jpg)
'With this we need to generate the image url eg/PATH TO DATABASE/WebFiles/KEY/$File/FILENAME
'WebFiles - is the view containing the image documents
'Key - is the filename id
'Filename - is the image filename with extension
intLoc2 = Instr(newText, " ")
fileID = Mid(newText, (Instr(newText, ":")+1), intLoc1-(Instr(newText, ":")+1))
If intLoc2 <> 0 Then
fileName = Left(Strright(newText, "!!"), Instr(Strright(newText, "!!"), " ")-1)<br/>
Else
fileName = Mid(newText, intLoc1+2, Len(newText)-(intLoc1-1))<br/>
End If
'The relative path name to the file in the resource document
fileWebPath = Evaluate(|"../webfiles/| & fileID & |/$file/| & fileName & |"|)
'Check if we're creating a file link or an image link
If Instr(newText, "image:")=1 Then
leftText = "image:" & fileWebPath(0)<br/>
Else
leftText = "file:" & fileWebPath(0)<br/>
End If
'The alignment (for images) or the link name (for files)
rightText = Strright(newText, " ")
Else
leftText = Strleft(newText, " ")
rightText = Strright(newText, " ")
End If