Hello there,
(post changed if your wondering i you have seen it before)
I have the following code that is mostly from google as a starting point:
Sub DocSearch()
Application.ScreenUpdating = False
Dim wdApp As Object, wdDoc As Object
Set wdApp = CreateObject("word.application")
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Open("C:\Users\Samsung\Desktop\Charlie Work\vba\word replacement\datetest.docx")
With wdDoc.Content.Find
.text = 4500
.Replacement.text = "4500xxxx"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
wdDoc.SaveAs ("C:\Users\Samsung\Desktop\Charlie Work\vba\word replacement\datetest did it work.docx")
wdDoc.Close
Set wdApp = Nothing: Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
however i cannot determine a way to use the code to replace an entire section of text, rather than just a part of it: e.g searching 4500 and replacing it with 45001111 if the text to replace is 4500xxxx
45001111xxxx
were i was wondering if it can be replaced as just:
45001111
hope that makes sence? any thoughts?
Bookmarks