Imports word = Microsoft.Office.Interop.Word
'Open new instance dim objApp as New Word.Application 'create new object of word application dim objDoc as New Word.Document 'create new object of word document objDoc = objApp.Documents.Open(//word file path to open file) objDoc.Activate() MessageBox.Show(objDoc.Content.Text) 'Shows the content from word file 'Dispose the word objects objDoc.Close() objApp.Quit() objDoc = Nothing objApp = Nothing
'Open new instance objApp = New Word.Application objDoc = New Word.Document objDoc = objApp.Documents.Add() 'add new word file to documents collection objDoc.Activate() ' activate newly created file objApp.Selection.TypeText("This the First text") 'insert string in word file objDoc.SaveAs(//Path of file to save) 'save word file 'Dispose the word objects objDoc.Close() objApp.Quit() objDoc = Nothing objApp = Nothing
Dim objApp As Word.Application Dim objDoc As Word.Document objApp = New Word.Application() objDoc = objApp.Documents.Open("//Path of a file to Open") objDoc.PrintOut( _ Background:=True, _ Append:=False, _ Range:=Word.WdPrintOutRange.wdPrintCurrentPage, _ Item:=Word.WdPrintOutItem.wdPrintDocumentContent, _ Copies:="1", _ Pages:="1", _ PageType:=Word.WdPrintOutPages.wdPrintAllPages, _ PrintToFile:=False, _ Collate:=True, _ ManualDuplexPrint:=False) objDoc.Close(); objApp.Quit(); objDoc = Nothing objApp = Nothing
Dim objApp As Word.Application Dim objDoc As Word.Document objApp = New Word.Application() objDoc = objApp.Documents.Open("//Path of a file to Open") oDoc.SaveAs(FileName:=.FileName.ToString.Replace(".doc", ".htm"), FileFormat:=Word.WdSaveFormat.wdFormatHTML) oDoc.Saved = True oDoc.Close(SaveChanges:=False) oDoc = Nothing