hi , i had created a new .doc file, in the coding part a single doc file is readed and writed to the new doc file ...
how can i continue the operation for reading multiple doc file and write it to a new doc file .....
Imports System.Windows.Forms
Imports word = Microsoft.Office.Interop.Word
Imports Microsoft.Office.Interop.Word
Imports System.Runtime.InteropServices
Public Class Form1
Dim flb As New System.Windows.Forms.FolderBrowserDialog
Dim fod As OpenFileDialog = New OpenFileDialog()
Dim objapp As New word.Application
Dim objdoc As New word.Document
Dim object1 As Object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
flb.RootFolder = Environment.SpecialFolder.MyComputer
flb.ShowNewFolderButton = False
Dim result As DialogResult = flb.ShowDialog
If (result = DialogResult.OK) Then
ListBox1.Items.Clear()
TextBox1.Text = flb.SelectedPath
For Each filename In Directory.GetFiles(flb.SelectedPath, "*.doc").Union(Directory.GetFiles(flb.SelectedPath, "*.rtf").ToArray())
Next
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Call readandwrite()
End Sub
Sub readandwrite()
Dim missing As Object = System.Reflection.Missing.Value
Dim oFals As Object = False
Dim oTru As Object = True
Dim obj1 As Object
obj1 = TextBox1.Text & "\sam1"
Try
objapp = New word.Application
objdoc = New word.Document
If ListBox1.Items.Count > 0 Then
For i As Integer = 0 To ListBox1.Items.Count - 1
Dim obj As Object = ListBox1.Items(i)
objdoc = objapp.Documents.Open(obj, missing, oTru, missing)
objapp = New word.Application
objdoc = New word.Document
objdoc = objapp.Documents.Add(obj)
objdoc.SaveAs(obj1)
objdoc.Activate()
objdoc.Close()
objapp.Quit()
objdoc = Nothing
objapp = Nothing
Next
End If
Catch ex As Exception
MsgBox("read error")
End Try
End Sub