Hi Anant,
I have to read the data from a table in MSWORD. Then I have to execute a macro which takes these inputs and generates a text file from it.
I am a newbie to
VB usage .Can you tell me in steps as to how do
i make the
VB script read the data from the MSWord Table.
An early response would be highly appreciated.
Regards
Priya
Quote:
quote:Originally posted by Anantsharma
HI,
Reading From Excel File :-
**************************************************
Dim ExcelApp As Excel.Application
Dim WS As Excel.Worksheet
Dim i As Integer
Dim stra As String
Set ExcelApp = CreateObject("excel.application")
ExcelApp.Workbooks.Open (CommonDialog1.filename)
Set WS = ExcelApp.ActiveWorkbook.Sheets("VendorSheet") ''Sheet
For i = 1 to 10
stra="a"+cstr(i)
Msgbox WS.Range(stra).value
Next i
Above code will read 10 lines and column a of Excel sheet.
Aa1,a2,a3......a10.
for other colums just create the range like "b1", "m10" etc.
Hope u got the point.
************************************************** *****
Reading from text file:-
*************************
'''Add reference to "MicroSoft Scripting runtime" to ur project
then
Dim Fso as new FileSystemObject
Dim FileToread As TextStream
Dim CurrentLine as String
Set FileToread = fso.OpenTextFile("C:\a.txt", ForReading)
Do Whiile FileToread.AtEndOfStream = False
CurrentLine=FileToread.ReadLine
msgbox CurrentLine
Loop
*******************************************
Writing to text file
***********************
Dim FileToWrite as TextStream
Set FileToWrite = Fso.OpenTextFile("C:\mytxtfile", ForWriting, True)
FileToWrite.WriteLine "This is Line 1"
FileToWrite.WriteLine "This is Line 2"
FileToWrite.Close
**************
Hope this helps..Good luck..Happy programming
B. Anant
|