I have the following VB.NET code that creates a Word document by opening a template and populating it with some of the fields from the windows form created in Visual Studio 2008.
The problem is that everytime it opens the document and populates it with the data, the Word document is named "Document1" and if there are already multiple documents open of the same template then it'll name it "Document2", "Document3" and so on.
Is there a way to have it named to "Quote Form - QuoteNumber", where the QuoteNumber is taken from the Windows Form WITHOUT saving the document because the end user has to decide where to save it I can not hard code where to save it.
Basically, rename the Word document something we want instead of the default Doc1, Doc2 etc.
Hope this is possible. Thank you in advance!
Private Sub ExportWord()
Dim oWord As Word.Application = CreateObject("Word.Application")
Dim oDoc As Word.Document = oWord.Documents.Add("\\myserver\my documents\Shared Interdepartmental Folders\Applications\Quote Form.dotx")
oWord.Visible = True
oDoc.Bookmarks.Item("QuoteNumber").Range.Text = txtMasterItemNo.Text & "-" & txtQuoteNumber.Text
oDoc.Bookmarks.Item("QuoteDate").Range.Text = txtQuoteDate.Text
oDoc.Bookmarks.Item("ExpirationDate").Range.Text = txtExpirationDate.Text
oWord = Nothing
oDoc = Nothing