none
Output data from word onto Notepad RRS feed

  • Question

  • Hello,

    Recently some user name has told me to start a new thread. I agreed with him.

    Here is the source code:

    Sub AllEntriesToDifferentFiles()
    Dim strX As String
    Dim x As Long

    Open "C:\Users\John\Documents\Roget\Pages 11 to 91\Document Cloud\Pages 42 to 109.txt" For Input As #1
    For x = 0 To 10
          Line Input #1, strX
          strX = strX + contents
    Next x
    Close #1

    Open "C:\Users\John\Documents\Text Number One.txt" For Output As #2
    Write #2, strX
    Close #2

    End Sub

    Although it prints only prints out line 10 from that file, it does not print the entire document in Notepad.

    Should I use a Do Until...Loop structure?

    JohnDBCTX

    Wednesday, June 15, 2016 3:08 AM

Answers

  • Hi JohnDBCTX,

    you not need to write these much line to do this.

    if you just want all the data of word file in text file then use the code below.

    Sub NowSaveme()
        ActiveDocument.SaveAs "C:\Users\v-padee\Desktop\deep1.txt", wdFormatText
    End Sub

    it will save entire document in text file.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 16, 2016 4:10 AM
    Moderator

All replies

  • Hi JohnDBCTX,

    you not need to write these much line to do this.

    if you just want all the data of word file in text file then use the code below.

    Sub NowSaveme()
        ActiveDocument.SaveAs "C:\Users\v-padee\Desktop\deep1.txt", wdFormatText
    End Sub

    it will save entire document in text file.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 16, 2016 4:10 AM
    Moderator
  • Hi, if you use vb.net, try following solution which is based on Word component.

    Imports Spire.Doc
    
    Namespace WordToTxt
    
        Class Program
    
            Private Shared Sub Main(args As String())
    		Dim doc As New Document()
    
            doc.LoadFromFile(fileName)
    		doc.SaveToFile("Text.txt", FileFormat.Txt)
    	End Sub
    
    End Class
    End Namespace


    Monday, June 20, 2016 2:47 AM
  • Hi JohnDBCTX,

    since you had created this thread you did not replied the suggestions given by the community members.

    The other things I want to confirm with you that are you interacting with Word Application.

    I did not see any kind of word usage in your above mentioned code. you are taking an input from txt file and save output in txt file.

    if you are not developing in MS Word Application using Word Object Model then you are in a wrong Forum. so please let us know so that we can try to provide a right way.

    If you are using Word Application and trying to code using Word object model then,

    I would like suggest you to check the suggestion given by members and if you think it worked for you then mark the suggestion as an Answer.

    if you had seen the suggestions already and you still having a problem then please let us know so that we can try to provide you further help.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, June 20, 2016 6:49 AM
    Moderator