Passing a file name(s) to a function
Below is a function from Tim Hastings (http://www.nonhostile.com/). This is a post from his blog. At the bottom of his code you can see he demonstrates his function with some html fed into the function.
I would like to know how you could use a function similar to this but instead of some html passed into the function...be able to pass the function a file or a group of files. How would you pass this function a file name or group of file names?
I'm thinking something like this...
Of course, this doesn't work. I think it has to do with the byVal reference in the function but I'm not sure and don't know what it should be. Any help is greatly appreciated. Thanks.
Dim HTMLFile As String
HTMLFile = Dir("C:\TEMP\" & "*.html")
Private Function HTMLClean(ByVal strText As String) As String
Dim objRegEx As VBScript_RegExp_55.RegExp
' replace <br>'s for a newline
strText = Replace$(strText, "<br>", Chr$(10), 1, -1, vbTextCompare)
' replace non-breaking spaces for a space
strText = Replace$(strText, " ", Chr$(32), 1, -1, vbTextCompare)
' create new regex object
Set objRegEx = New VBScript_RegExp_55.RegExp
objRegEx.Global = True ' don't just operate on first find.
' remove HTML tags
objRegEx.Pattern = "<[^>]*>"
strText = objRegEx.Replace(strText, "")
' ditch excessive white space
objRegEx.Pattern = "\s+"
strText = objRegEx.Replace(strText, " ")
' thanks, bye
Set objRegEx = Nothing
strText = Replace$(strText, ">", ">", 1, -1, vbTextCompare)
strText = Replace$(strText, "<", "<", 1, -1, vbTextCompare)
' insert your favourite named-entities here.
strText = Replace$(strText, "&", "&", 1, -1, vbTextCompare) ' must do last
HTMLClean = strText
Debug.Print HTMLClean("<greets>Hello <oh> &" & vbNewLine & _
"<b>I</b> <a href=""#"">wonder</a> " & vbNewLine & _
" what<br>will become of all this?</greets>")
Hello <oh> &I wonder what will become of all this?