Reading data from a word file and opening the file with the data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xips
    New Member
    • Feb 2008
    • 3

    Reading data from a word file and opening the file with the data

    I have a word document which contains file names (1 per line)

    I want to use word macro to open that doc, pick the contents on line 1 and open the file from a specific path, edit the file and close it.

    I want to read the next file name from the next line and do the above for all the lines in the document.
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    Have you attempted this at all?

    Which part are you stuck with..?

    Comment

    • xips
      New Member
      • Feb 2008
      • 3

      #3
      James,
      I opened the word file and copied the contents.

      I need to know how to copy it to a variable?

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        See if this example helps.

        Usage
        [code=vbnet]
        dim a as string = Readfile(a)
        [/code]

        [code=vbnet]
        Function Readfile(ByVal abc)
        Dim EntireLine As String
        Dim oFile As System.IO.File
        Dim oRead As System.IO.Strea mReader
        oRead = oFile.OpenText( "C:\PasswordUpd ate.doc")
        EntireLine = oRead.ReadToEnd
        oRead.Close()
        Return EntireLine
        End Function
        [/code]

        Comment

        • xips
          New Member
          • Feb 2008
          • 3

          #5
          James,

          I have used Selection.copy to copy a filename in Word macro.

          Can I copy it to a variable?

          Then I should be able to open a file which using the content of the variable instead of using the actual file name directly.

          Comment

          Working...