Bonjour,
Dans son message, < carl > écrivait :
In this message, < carl > wrote:
|| guys
|| I'm running Word97 and the VB library is
|| missing "Replace". Since it is a work computer I can't
|| change or add to the VB library.
|| This there a work around? The specific code i need to run
|| is
|| strCmd = Replace(strCmd, "%1", strDoc)
|| which comes up with "sub or function not defined" ...
|| the 'Replace' is highlighted
The Replace Function was not included in the Office 97 libraries (Except in
Excel where it is not the usual VB Replace, but the Excel Replace).
You can use this function:
'_______________________________________
Public Function ReplaceStr(ByVal MainString As String, _
ByVal RepThis As String, _
ByVal WithThis As String) As String
Dim i As Long
While Left(MainString, Len(RepThis)) = RepThis
MainString = WithThis & _
Mid(MainString, Len(RepThis) + 1)
Wend
While InStr(2, MainString, RepThis) > 0
i = InStr(2, MainString, RepThis)
MainString = Left(MainString, i - 1) _
& WithThis & Mid(MainString, i + Len(RepThis))
Wend
ReplaceStr = MainString
End Function
'_______________________________________
Call it like:
'_______________________________________
Sub TestReplace()
Dim BigString As String
Dim NewBigString As String
BigString = "Put as much text as you want here..."
NewBigString = ReplaceStr(BigString, "Put", "Type")
End Sub
'_______________________________________
or, in your case
'_______________________________________
strCmd = ReplaceStr(strCmd, "%1", strDoc)
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org