G
Greg Maxey
I have a letterhead template that can have one to four addressees arranged
in a table.
I have another template for creating mailing labels (six per sheet). When
this template is used to create a new document it presents a Userform with
controls for filling in data in each of the six possible slots. This allows
the user to print 1 to 6 different labels to any slot on the label sheet.
I now face the challenge of bringing these two templates together. I am
trying to figure out how I can open and create an new letterhead (with one
to four addressees) then run a macro from that letterhead template that
creates a new label document. I have gotten as far as that. I have a macro
in the letterhead document that creates a new sheet of labels based on the
label template. When the new label document is created the UserForm is
display.
The code looks like this:
Option Explicit
Public oTblPublic As Word.Table
Sub CreateLabels()
Const EnvTempPath As String = "F:\My Documents\Word\Paid Work\Stein
Consulting\Fairfield\Practice Labels.dot"
Dim oPar As Paragraph
Dim oLetter As Word.Document
Dim oEnvDoc As Word.Document
Set oLetter = ActiveDocument
Set oTblPublic = oLetter.Tables(1)
Set oEnvDoc = Documents.Add(Template:=EnvTempPath)
End Sub
With the new label document now in front of me with the Userform displayed,
I need access to the information stored in the letterhead addreesee table
(oTblPublic). I don't know that must about public variables, but I thought
if a variable was declared as Public then it would be available to all
modules in all open projects. I must be wrong as I get an error when I try
something like this in the label document project:
Sub Test
Msgbox oTblPulic.Cell(1,4).Range.Text
End SUb
Saying that the variable is not declared.
Thanks for any explaination or help.
in a table.
I have another template for creating mailing labels (six per sheet). When
this template is used to create a new document it presents a Userform with
controls for filling in data in each of the six possible slots. This allows
the user to print 1 to 6 different labels to any slot on the label sheet.
I now face the challenge of bringing these two templates together. I am
trying to figure out how I can open and create an new letterhead (with one
to four addressees) then run a macro from that letterhead template that
creates a new label document. I have gotten as far as that. I have a macro
in the letterhead document that creates a new sheet of labels based on the
label template. When the new label document is created the UserForm is
display.
The code looks like this:
Option Explicit
Public oTblPublic As Word.Table
Sub CreateLabels()
Const EnvTempPath As String = "F:\My Documents\Word\Paid Work\Stein
Consulting\Fairfield\Practice Labels.dot"
Dim oPar As Paragraph
Dim oLetter As Word.Document
Dim oEnvDoc As Word.Document
Set oLetter = ActiveDocument
Set oTblPublic = oLetter.Tables(1)
Set oEnvDoc = Documents.Add(Template:=EnvTempPath)
End Sub
With the new label document now in front of me with the Userform displayed,
I need access to the information stored in the letterhead addreesee table
(oTblPublic). I don't know that must about public variables, but I thought
if a variable was declared as Public then it would be available to all
modules in all open projects. I must be wrong as I get an error when I try
something like this in the label document project:
Sub Test
Msgbox oTblPulic.Cell(1,4).Range.Text
End SUb
Saying that the variable is not declared.
Thanks for any explaination or help.