Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace a string in a word document with another string
#6
Solved: 10 Years, 9 Months, 2 Weeks ago
This should work better, and you weren't calling save:

Quote:Set obj_word = CreateObject("Word.Application")
Set obj_doc = obj_word.documents.Open("D:\QTP Practice\QTP.docx")
Set obj_words = obj_doc.Words

For i = 1 To obj_words.Count
obj_words.Item(i).Text = Replace(obj_words.Item(i).Text, "QTP", "Mercury")
Next

obj_doc.Save
obj_doc.Close
obj_word.Quit
Set obj_words = Nothing
Set obj_doc = Nothing
Set obj_word = Nothing
Reply


Messages In This Thread
RE: Replace a string in a word document with another string - by cdesserich - 10-01-2010, 02:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split function in string nidhishnair 13 63,436 07-07-2020, 03:47 PM
Last Post: helmzshelmz
  String Array Declaration Bhuvana 0 917 01-07-2020, 12:59 PM
Last Post: Bhuvana
  How to remove the spaces from a string Anand 7 28,508 08-12-2019, 04:47 PM
Last Post: sreekanthP
  String Manipulation engr.awaiszafar@gmail.com 0 1,395 10-11-2018, 11:44 AM
Last Post: engr.awaiszafar@gmail.com
  Split a string with multiple delimiters in VBScript nandha 2 7,993 02-10-2018, 06:44 PM
Last Post: nandha

Forum Jump:


Users browsing this thread: 1 Guest(s)