Thursday, April 21, 2011

How to read values from a word doc file using VBScript

Can anyone tell me how to read values from a word.doc file using VBScript. I had given a sample.doc file below.

Parameters              Default Values
-----------------------------------------------------
No of values            8192 
Sampling Frequency      12800
Frequency Hop           2000
No of times             2

The above one is given in a table.

From stackoverflow
  • Here are some notes.

    Set wd = CreateObject("Word.Application")
    wd.Visible = True
    
    wd.Documents.Open "C:\Docs\Tables.doc"
    
    For Each t In wd.ActiveDocument.Tables
        s = s & "Table" & vbcrlf
        For i = 1 To t.Rows.Count
            For Each c In t.Rows(i).Cells
                s = s & Replace(c.Range.Text, vbCr & Chr(7), "")
            Next
            s = s & vbcrlf
        Next
    Next
    
    MsgBox s
    
  • These Links should help
    Word object model

    Document Class

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.