Replace() -- Syntax Error
Posted on 2005-04-26
--Dim currname As String
--currname = ActiveDocument.FullName
work? (at least in Word 2003's implementation of VBA)? I get, "Compile Error. Expected =" I think I am faithfully following the syntax described in the Word/VB help file (see end of this posting), but obviously I am not if I get an error message. My goal is to create a string variable equal to the complete filename but with any spaces replaced with "%20" (minus the quotes). The result will be a click-able hyperlink when pasted into an email.
FROM WORD/VBA HELP FILE
Description -- Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Syntax -- Replace(expression, find, replace[, start[, count[, compare]]])
-- expression = String expression containing substring to replace.
-- find = Substring being searched for.
-- replace = Replacement substring.
-- start (Optional) = Position within expression where substring search is to begin. If omitted, 1 is assumed.
-- count (Optional) = Number of substring substitutions to perform. If omitted, the default value is –1, which means make all possible substitutions.
-- compare (Optional) = Numeric value indicating the kind of comparison to use when evaluating substrings where:
== vbUseCompareOption –1 Performs a comparison using the setting of the Option Compare statement.
== vbBinaryCompare 0 Performs a binary comparison.
== vbTextCompare 1 Performs a textual comparison.
== vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based on information in your database.