+ Reply to Thread
Results 1 to 5 of 5

Delete specific characters and save as txt

  1. #1
    Forum Contributor
    Join Date
    12-27-2021
    Location
    China
    MS-Off Ver
    Ms office 2019
    Posts
    276

    Exclamation Delete specific characters and save as txt

    Hello, how can I delete a specific string of a word document and save it as a TXT document.

    In the document, each paragraph begins with the word "From". When another word "to" appears, all strings from the word "From" to the word "to" are deleted (including "From" and "to". The string length is uncertain).

    Each word document has more than 100 pages, and there are more than 100 word documents in total. When saving as txt, the name of the word document should be the same as that of the corresponding word document.

    The saved txt document needs to be encoded in UTF-8

    Thanks a lot!
    Attached Files Attached Files
    Last edited by 302; 11-23-2022 at 02:54 AM.

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,831

    Re: Delete specific characters and save as txt

    All you need is a wildcard Find/Replace, where:
    Find = From*to
    Replace = nothing
    then save the document as a text file.

    For code you can adapt to automate this, see: https://www.msofficeforums.com/word-...ocx-files.html. The code there does everything except save the edited documents as text files. I'll leave it to you to add that part.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    12-27-2021
    Location
    China
    MS-Off Ver
    Ms office 2019
    Posts
    276

    Re: Delete specific characters and save as txt

    thanks a lot , macropod. Your code runs very well, but I'm not familiar with Word VBA. I don't know how to batch convert it to TXT UTF-8 format. Can you help me to modify the code?

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,831

    Re: Delete specific characters and save as txt

    Everything you need is in the link I posted - including code showing how to save a file. All you need do is supply the required Find/Replace expressions and insert the .SaveAs code with the applicable parameters. You shouldn't expect to be spoon-fed everything. Time for you to start learning Word VBA.

  5. #5
    Forum Contributor
    Join Date
    12-27-2021
    Location
    China
    MS-Off Ver
    Ms office 2019
    Posts
    276

    Re: Delete specific characters and save as txt

    ok, thanks for your advice. thanks again.

+ 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. Copy Worksheet , save in specific locatino, save as specific name, save as CSV
    By wherdzik in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2022, 08:40 PM
  2. formula required to delete specific characters from between a lin
    By sparkerk5 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-02-2019, 06:40 PM
  3. [SOLVED] How to delete cells and rows with specific Characters using VBA
    By priyadharshane in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 01-25-2019, 01:20 PM
  4. [SOLVED] Macro to delete all characters after the second number 1 in specific cell
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-07-2018, 09:22 AM
  5. [SOLVED] Delete specific characters from right side of string
    By Drudnits1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-29-2014, 02:12 PM
  6. [SOLVED] If cell contains 3 or more specific characters then delete row
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2014, 08:12 AM
  7. [SOLVED] Delete characters and add * in front and last characters in ACCESS QUERY
    By LALTIZER in forum Access Tables & Databases
    Replies: 9
    Last Post: 02-01-2013, 02:06 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