Reputation: 463
If Anyone happens to know, how would I create a word document that is a blank page of labels? There are a million and one guides to performing a mail merge, but I am not looking to do that. I simply want a blank word document that I will throw sequential numbers in.
I have created the document as such...
Dim oWord As Word.Application
Dim oDoc As Word.Document
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
This creates and opens a simple word document. How would I insert into the document a label page? The type of label is irrelevant, I am hoping to be able to tell from its creation how to interact with it as needed.
Any and all help help is greatly appreciated!
Upvotes: 0
Views: 574
Reputation: 463
The solution is listed below.
Dim oWord As Word.Application
Dim oDoc As Word.Document
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
oDoc = oWord.MailingLabel.CreateNewDocument(Name:="L7163", Address:="This is some text", AutoText:="MyLabelLayout", LaserTray:=Nothing)
This creates a single page of mailing labels with "This is some text" displayed on each. The version of the mailing labels is Avery L7163. The only problem is that it creates the initial active document and a second label page. This is resolved as such..
Dim oWord As Word.Application
Dim oDoc As Word.Document
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
Dim ActiveDoc = oWord.ActiveDocument
ActiveDoc = oWord.MailingLabel.CreateNewDocument(Name:="L7163", Address:="sdvsdv", AutoText:="MyLabelLayout", LaserTray:=Nothing)
oDoc.Close(False, , )
This does the same thing except it sets the labels as the active document and then closes the blank document.
Upvotes: 1