G
Georgios Liakopoulos
Hi,
I find and replace text in a .doc file using MS Access visual basic.
Here is my Sub:
***************************************************************
Public Sub ReplaceText(obj As Word.Application, vSource As String, vDest
As String)
'Replace all occurences of vSource with vDest in Word doc
obj.ActiveDocument.Content.Find.Execute FindText:=vSource, _
ReplaceWith:=vDest, Format:=True, _
Replace:=wdReplaceAll
End Sub
***************************************************************
I pass through the vSource string using another sub like:
*****************************************************
.. . .
Dim objWord As Word.Application
.. . .
Set objWord = New Word.Application 'create instance of Word
objWord.Documents.Add "C:\Documents and
Settings\Labuser\Desktop\AddRefs.doc" 'open document (vFilename)
objWord.ScreenUpdating = False 'turn off screen updates
.. . .
If ActiveDocument.Content.Find.Execute(FindText:="FIXED
STRING") = True Then
.. . .
ReplaceText objWord, "FOUND FIXED STRING"
.. . .
****************************************************
My Question:
Can I search text using wildcards?, like:
****************************************************
If ActiveDocument.Content.Find.Execute(FindText:="(PRODUCT CODE: "*")")
= True Then
*****************************************************
Thank you for reading
Georgios
I find and replace text in a .doc file using MS Access visual basic.
Here is my Sub:
***************************************************************
Public Sub ReplaceText(obj As Word.Application, vSource As String, vDest
As String)
'Replace all occurences of vSource with vDest in Word doc
obj.ActiveDocument.Content.Find.Execute FindText:=vSource, _
ReplaceWith:=vDest, Format:=True, _
Replace:=wdReplaceAll
End Sub
***************************************************************
I pass through the vSource string using another sub like:
*****************************************************
.. . .
Dim objWord As Word.Application
.. . .
Set objWord = New Word.Application 'create instance of Word
objWord.Documents.Add "C:\Documents and
Settings\Labuser\Desktop\AddRefs.doc" 'open document (vFilename)
objWord.ScreenUpdating = False 'turn off screen updates
.. . .
If ActiveDocument.Content.Find.Execute(FindText:="FIXED
STRING") = True Then
.. . .
ReplaceText objWord, "FOUND FIXED STRING"
.. . .
****************************************************
My Question:
Can I search text using wildcards?, like:
****************************************************
If ActiveDocument.Content.Find.Execute(FindText:="(PRODUCT CODE: "*")")
= True Then
*****************************************************
Thank you for reading
Georgios