Results 1 to 4 of 4

Thread: sending word text to a .txt file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    83

    Resolved sending word text to a .txt file

    Is there a way to select all of the text on an open word document through vba and send it to a .txt file?

    Also could this be done continuously so that the word document and text file contain the same words?

    What about formatting in word, is there a way of getting past this so that extra white space is not sent to the txt file?

    Thanks
    Last edited by smileyface5; Feb 17th, 2005 at 12:16 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sending word text to a .txt file

    You mean like some kind of logger that writes the keypresses out to a textfile? Word already makes
    backup copies of the document when it is being worked on, if the option is selected.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    83

    Re: sending word text to a .txt file

    i need to run a perl module on the text. It works if run it on a .txt file however with all the formatting in word it goes crazy and cannot read it. Therefore i am sending all the text in the word document to a .txt file.

    I would like to do it on keypress which i think would be done using a loop?

    Also i am afraid that the formatting might still be sent to the .txt file and cause problems

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: sending word text to a .txt file

    Soundslike allot of issues may arrise if you do it on the keypress. You can do the
    entire doc using the SaveAs method.

    VB Code:
    1. ActiveDocument.SaveAs FileName:="C:\DocumentText.txt", FileFormat:=wdFormatDOSText
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width