
.NET ile Word Kullanımı
Yeni bir Word belgesi oluşturup kaydetmek için;
Dim WordApp As New Word.Application
Dim WordDoc As New Word.Document
WordDoc = WordApp.Documents.Add()
WordDoc.Range.InsertAfter(TextBox1.Text)
WordDoc.SaveAs(Application.StartupPath & "\deneme.doc")
WordDoc.Close()
WordApp.Quit()
Önceden kaydedilmiş bir belgeyi açmak için;
Dim WordApp As New Word.Application
Dim WordDoc As New Word.Document
Dim Sayac As Integer
WordDoc = WordApp.Documents.Open(Application.StartupPath & _ "\deneme.doc")
For Sayac = 1 To WordDoc.Words.Count - 1
TextBox2.AppendText(WordDoc.Words(Sayac).Text)
Next
WordDoc.Close()
WordApp.Quit()
Yazdırma işlemi için;
Dim WordApp As New Word.Application
Dim WordDoc As New Word.Document
WordDoc = WordApp.Documents.Open(Application.StartupPath &_ "\deneme.doc")
WordDoc.PrintOut()
WordDoc.Close()
WordApp.Quit()
.NET ile Excel Kullanımı
Yeni bir Excel belgesi oluşturup kaydetmek için;
Dim ExcelApp As New Excel.Application
Dim ExcelWorkSheet As New Excel.Worksheet
ExcelWorkSheet = ExcelApp.Workbooks.Add.Worksheets.Add
ExcelWorkSheet.Cells(1, 1) = "Selam dünyalı biz dostuz"
ExcelWorkSheet.SaveAs(Application.StartupPath & "\deneme.xls")
ExcelApp.Quit()
Önceden kaydedilmiş bir belgeyi açmak için;
Dim ExcelApp As New Excel.Application
Dim ExcelWorkSheet As New Excel.Worksheet
ExcelApp.Workbooks.Open(Application.StartupPath & "\deneme.xls")
ExcelWorkSheet = ExcelApp.Workbooks.Item(1).Worksheets("Sayfa4")
TextBox3.Text = ExcelWorkSheet.Cells(1, 1).Text
ExcelApp.Quit()
ads
Hiç yorum yok: