+ Reply to Thread
Results 1 to 3 of 3

Open And Close .txt File With A Search And Replace

  1. #1
    Forum Contributor
    Join Date
    12-22-2004
    Location
    Kokomo, Indiana
    Posts
    236

    Question Open And Close .txt File With A Search And Replace

    I have multiple .txt files which I get as data files. Inside these files there are two types of character sequences which I would like to delete. The first is: < lots of text > and the second is: < lots of text>, . The <> has all sorts of formatting stuff not relevant to my needs. I want to delete all references to these character groups. Note the comma shown on the second character string after the >. How can I open a text file from inside Word without actually displaying the data and removing these formatting < > / < >, strings? I would like to do this in VBA for Word. Lastly I'd like to Save the File as a .txt but with the word "Modified" tacked on to the beginning of the file name. Your assistance would be amazing. Thank you in advance.

    Tony

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Open And Close .txt File With A Search And Replace

    Please attach one sample of this file for test purposes.

    Are you looking for all occurrences of any text that occurs inside "<>" or "<>,"?

    What do you mean by this: "without actually displaying the data"? It is possible to open a Word file from VBA without showing the application on the screen. Is that what you mean?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Open And Close .txt File With A Search And Replace

    Is it necessary to use Word? I use Notepad++ (a free open source text/code editor) for a few text operations, and one of the available commands is "Find and replace in files". I'm sure there are other text editors with similar commands. It might be possible to find a text editor with the built in ability to find and replace the desired text in your files without needing to write your own code to do it.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 07-18-2017, 04:51 PM
  2. [SOLVED] VBA Open File/Run Macro/Close &Save/Open Next File
    By JPSIMMON in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-21-2015, 12:16 PM
  3. Problem With Open File and Save File With Saveas and then close the File
    By John Vieren in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-27-2013, 12:53 AM
  4. Open 2nd file(CSV) from cell reference, copy columns to main file & close 2nd file
    By Langchop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2013, 05:09 AM
  5. Check if a Word File is Open and If Open Close it with Excel VBA.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2012, 11:14 AM
  6. How to: Open file, format data, save file, close file and repeat.
    By thexeber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2010, 12:56 PM
  7. Open Another File to Search and Replace Text
    By Ricky Pang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2006, 01:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1