I need to create a new ms word document with my desired given name using vb.net.
For that i have written a simple code as below
Dim wordApp As Microsoft.Office.Interop.Word.Application
Dim wordDoc As Microsoft.Office.Interop.Word.
wordApp = New Microsoft.Office.Interop.Word.Application
wordDoc = wordApp.Documents.Add
wordApp.Visible = True
This code runs perfectly, but i want to create a new document with my given name.
I want to give it name as "Order No. 1"
where the text "Order No." will be static and the number will be fetched from database and added +1
for that i have tried
Dim wordName as Object "Order No."
wordDoc = wordApp.Documents.Add(wordName)
but this line gives error.
COMException was unhandled
Word was unable to read this document. It may be currupt.
Try one or more of the following:
* Open and Repair the file.
Whats the error in my code, please inform me.
More i want to ask you is that i have searched in google
where every one use Word.Application, but i have to use Microsoft.Office.Interop.Word.Application
where i have imported Microsoft.Office.Interop.Word.
Give Proper Solution.
Thanks
Dhavall VadherPosted Jul 19, 2010, 6:18 AM
Thanks for ur instant reply, but the link you have given, i also have taken reference from the same source
I also have downloaded this code but it could not run on my pc, because of version mis-match.
Dinesh BeniwalPosted Jul 19, 2010, 5:10 AM
http://www.vbdotnetheaven.com/Uploadfile/mgold/WordDocument04182005081441AM/WordDocument.aspx