newguy
Well-known member
Hi All.
Got some bits a pieces during my quest to learn office automation, part of this works, it opens the template as a new doc1 of the template, prints the last listbox.item only, and then save the file in the appdata(?) file location, instead of the one I want, what am I missing???
Class variables:
Code in the save btn.:
Thanks for the help...
Got some bits a pieces during my quest to learn office automation, part of this works, it opens the template as a new doc1 of the template, prints the last listbox.item only, and then save the file in the appdata(?) file location, instead of the one I want, what am I missing???
Class variables:
VB.NET:
Dim oWord As Microsoft.Office.Interop.Word.Application
Dim oDoc As Microsoft.Office.Interop.Word.Document
Dim oPar As word.Range
Code in the save btn.:
VB.NET:
Try
oWord = word.Application
oWord = CType(CreateObject("Word.Application"), word.Application)
oDoc = oWord.Documents.Add(Template:=txtFolderLoc.Text & "\Report.dot")
Dim save As Object = False
Dim dest As Object = txtFolderLoc.Text & "\"
For Each item In ListBox2.Items.ToString
oPar.Text = item
Next
oWord.Visible = True
oDoc.SaveAs(dest & txtFileName.Text)
oWord.Quit(save)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Thanks for the help...
Last edited: