Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to do replace strings in Vbscript

How to do replace strings in Vbscript

Scheduled Pinned Locked Moved Visual Basic
tutorialtoolshelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xylan
    wrote on last edited by
    #1

    Hi I am using the following code to replace a string in VbScript. Documents.Closeall Documents.Open FileName.txt, "Text" ActiveDocument.Selection.StartOfDocument blnFound = ActiveDocument.Selection.FindText(String) If blnFound = true Then ActiveDocument.ReplaceText String "ReplaceStr 2.2" MsgBox "Hello World!", 65, "MsgBox Example" End If ActiveDocument.Save FileName.txt My filename.txt looks like this: string 2.3,002 4 The script replaces "String" with "ReplaceStr 2.2", but I also want to replace all the part following string i.e 2.3,002 4. I want my filename to look like this after the script is run: ReplaceStr 2.2 instead of ReplaceStr 2.2 2.3,002 4 Any help will be very much apprciated. Thanks

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups