#1   Report Post  
Posted to microsoft.public.word.docmanagement
chaucersmom chaucersmom is offline
external usenet poster
 
Posts: 15
Default Shipping Label Design

I can't get labels to work on Word 2007. I've looked at the posts and help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone have a
program that will help automate this? I just print it out on regular paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in WordPerfect,
but I want to be able to choose the address from my Outlook Contacts. Anyway
to do that?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

This may be too complicated for you, but if you do set it up, it will do all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu and
then place a check mark against the Microsoft Word ##.0 Object Library (##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the Toolbar
at the top of the screen and select Customize, then on the Toolbars tab of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in it.

If you want, in the Contacts screeen in Outlook, if you right click on the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?


  #3   Report Post  
Posted to microsoft.public.word.docmanagement
chaucersmom chaucersmom is offline
external usenet poster
 
Posts: 15
Default Shipping Label Design

Thanks Doug for your response. Even though your solution was probably much
more complicated than I have ever tried, your directions were fantastic. I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping label" on
the toolbar and an error message came up: "User-defined type not defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label, rather
than using Ctr F9. I doubt, though, that this caused the error since it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will do all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu and
then place a check mark against the Microsoft Word ##.0 Object Library (##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the Toolbar
at the top of the screen and select Customize, then on the Toolbars tab of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in it.

If you want, in the Contacts screeen in Outlook, if you right click on the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?



  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

You have missed this part of my instructions:

While in the Visual Basic Editor, select References from the Tools menu and
then place a check mark against the Microsoft Word ##.0 Object Library (##
will vary depending upon the version of Word that you are using.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Thanks Doug for your response. Even though your solution was probably
much
more complicated than I have ever tried, your directions were fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping label" on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label,
rather
than using Ctr F9. I doubt, though, that this caused the error since it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars tab
of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone
have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?




  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

Also, you cannot just copy and paste the

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

You could however copy and paste

DOCVARIABLE varname
DOCVARIABLE varcompany
DOCVARIABLE varstreet
DOCVARIABLE varcity DOCVARIABLE varstate DOCVARIABLE varzip
DOCVARIABLE varcountry

and then select each of the words DOCVARIABLE and the word after it in turn
and then press Ctrl+F9 to enclose it in Field Delimiters.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Thanks Doug for your response. Even though your solution was probably
much
more complicated than I have ever tried, your directions were fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping label" on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label,
rather
than using Ctr F9. I doubt, though, that this caused the error since it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars tab
of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone
have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
gr8auntieokie gr8auntieokie is offline
external usenet poster
 
Posts: 108
Default Shipping Label Design

Doug, I decided to see if _I_ could create your macro in Outlook, too. The
macro in Outlook is okay, but when I click on the contact name and then click
on the "MakeShippingLabel" button in my custom toolbar, a Word window opens
but nothing else happens. (If it matters, I did modify the macro so it would
search for the name of my Word template, changing the Word template from
"ShippingLabel.dot" to "MakeLabl.dot.")

Our firm stores all our documents, templates, etc. in Worldox (a document
management software) and I'm wondering if the path through Worldox to my
template might be what's stopping the Outlook macro from working. Any ideas??

Thanks.
Cyndie Browning
Software Support Specialist
GableGotwals
Tulsa, OK


"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will do all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu and
then place a check mark against the Microsoft Word ##.0 Object Library (##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the Toolbar
at the top of the screen and select Customize, then on the Toolbars tab of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in it.

If you want, in the Contacts screeen in Outlook, if you right click on the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

Do you have the DOCVARIABLE fields in your template?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in message
...
Doug, I decided to see if _I_ could create your macro in Outlook, too. The
macro in Outlook is okay, but when I click on the contact name and then
click
on the "MakeShippingLabel" button in my custom toolbar, a Word window
opens
but nothing else happens. (If it matters, I did modify the macro so it
would
search for the name of my Word template, changing the Word template from
"ShippingLabel.dot" to "MakeLabl.dot.")

Our firm stores all our documents, templates, etc. in Worldox (a document
management software) and I'm wondering if the path through Worldox to my
template might be what's stopping the Outlook macro from working. Any
ideas??

Thanks.
Cyndie Browning
Software Support Specialist
GableGotwals
Tulsa, OK


"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars tab
of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone
have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?




  #8   Report Post  
Posted to microsoft.public.word.docmanagement
chaucersmom chaucersmom is offline
external usenet poster
 
Posts: 15
Default Shipping Label Design

Doug,

Thanks for your patience with my Shipping Label project and my ineptitude!

The "Make Shipping Label" button on the toolbar wouldn't run the program.
So I ran the Macro from the Macro menu and the error message I got was: "The
Macros in this project are disabled."

I went to the Trust Center, Macro Security in Outlook. The box checked
was the second one -- warnings for unsigned macros. Then I went to the Trust
Center in Word and checked the box Trust Access to VBA project model. Now
when I click on the Make Shipping Label button, a small box appears on the
Contacts screen with the First and Last name of the contact and that's all
that happens. MS Word doesn't open.

I am using Word 2007 and Outlook 2007. I saved my templates file as a .dotx
file. Any suggestions?


"Doug Robbins - Word MVP" wrote:

You have missed this part of my instructions:

While in the Visual Basic Editor, select References from the Tools menu and
then place a check mark against the Microsoft Word ##.0 Object Library (##
will vary depending upon the version of Word that you are using.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Thanks Doug for your response. Even though your solution was probably
much
more complicated than I have ever tried, your directions were fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping label" on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label,
rather
than using Ctr F9. I doubt, though, that this caused the error since it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars tab
of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone
have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?




  #9   Report Post  
Posted to microsoft.public.word.docmanagement
gr8auntieokie gr8auntieokie is offline
external usenet poster
 
Posts: 108
Default Shipping Label Design

Yes.


"Doug Robbins - Word MVP" wrote:

Do you have the DOCVARIABLE fields in your template?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in message
...
Doug, I decided to see if _I_ could create your macro in Outlook, too. The
macro in Outlook is okay, but when I click on the contact name and then
click
on the "MakeShippingLabel" button in my custom toolbar, a Word window
opens
but nothing else happens. (If it matters, I did modify the macro so it
would
search for the name of my Word template, changing the Word template from
"ShippingLabel.dot" to "MakeLabl.dot.")

Our firm stores all our documents, templates, etc. in Worldox (a document
management software) and I'm wondering if the path through Worldox to my
template might be what's stopping the Outlook macro from working. Any
ideas??

Thanks.
Cyndie Browning
Software Support Specialist
GableGotwals
Tulsa, OK


"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars tab
of
the Customize dialog, click on New then give the new Toolbar a name, say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar. Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with an
address from my Outlook contacts and a return address. Does someone
have
a
program that will help automate this? I just print it out on regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook Contacts.
Anyway
to do that?




  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

If you press Alt+F9 in the Word window that opens, do you see the field
codes in the document?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in message
...
Yes.


"Doug Robbins - Word MVP" wrote:

Do you have the DOCVARIABLE fields in your template?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in
message
...
Doug, I decided to see if _I_ could create your macro in Outlook, too.
The
macro in Outlook is okay, but when I click on the contact name and then
click
on the "MakeShippingLabel" button in my custom toolbar, a Word window
opens
but nothing else happens. (If it matters, I did modify the macro so it
would
search for the name of my Word template, changing the Word template
from
"ShippingLabel.dot" to "MakeLabl.dot.")

Our firm stores all our documents, templates, etc. in Worldox (a
document
management software) and I'm wondering if the path through Worldox to
my
template might be what's stopping the Outlook macro from working. Any
ideas??

Thanks.
Cyndie Browning
Software Support Specialist
GableGotwals
Tulsa, OK


"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module
into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from
that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that
appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts
and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with
an
address from my Outlook contacts and a return address. Does
someone
have
a
program that will help automate this? I just print it out on
regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook
Contacts.
Anyway
to do that?







  #11   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

The code should run without any changes to the Security Settings.

The box that you see containing the First and Last Name, should not really
appear but it does because when testing I had inserted a line of code

MsgBox cname

You can delete that if you do not want it.

If your template was saved as a .dotx, you will need to replace this line of
code

Set olabel = oWord.Documents.Add("ShippingLabel.dot")

with

Set olabel = oWord.Documents.Add("ShippingLabel.dotx")



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Doug,

Thanks for your patience with my Shipping Label project and my ineptitude!

The "Make Shipping Label" button on the toolbar wouldn't run the program.
So I ran the Macro from the Macro menu and the error message I got was:
"The
Macros in this project are disabled."

I went to the Trust Center, Macro Security in Outlook. The box checked
was the second one -- warnings for unsigned macros. Then I went to the
Trust
Center in Word and checked the box Trust Access to VBA project model.
Now
when I click on the Make Shipping Label button, a small box appears on the
Contacts screen with the First and Last name of the contact and that's all
that happens. MS Word doesn't open.

I am using Word 2007 and Outlook 2007. I saved my templates file as a
.dotx
file. Any suggestions?


"Doug Robbins - Word MVP" wrote:

You have missed this part of my instructions:

While in the Visual Basic Editor, select References from the Tools menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Thanks Doug for your response. Even though your solution was probably
much
more complicated than I have ever tried, your directions were
fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping label"
on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label,
rather
than using Ctr F9. I doubt, though, that this caused the error since it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module
into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from
that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that
appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts
and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with
an
address from my Outlook contacts and a return address. Does
someone
have
a
program that will help automate this? I just print it out on
regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook
Contacts.
Anyway
to do that?





  #12   Report Post  
Posted to microsoft.public.word.docmanagement
gr8auntieokie gr8auntieokie is offline
external usenet poster
 
Posts: 108
Default Shipping Label Design

Yes, the codes are there.


"Doug Robbins - Word MVP" wrote:

If you press Alt+F9 in the Word window that opens, do you see the field
codes in the document?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in message
...
Yes.


"Doug Robbins - Word MVP" wrote:

Do you have the DOCVARIABLE fields in your template?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in
message
...
Doug, I decided to see if _I_ could create your macro in Outlook, too.
The
macro in Outlook is okay, but when I click on the contact name and then
click
on the "MakeShippingLabel" button in my custom toolbar, a Word window
opens
but nothing else happens. (If it matters, I did modify the macro so it
would
search for the name of my Word template, changing the Word template
from
"ShippingLabel.dot" to "MakeLabl.dot.")

Our firm stores all our documents, templates, etc. in Worldox (a
document
management software) and I'm wondering if the path through Worldox to
my
template might be what's stopping the Outlook macro from working. Any
ideas??

Thanks.
Cyndie Browning
Software Support Specialist
GableGotwals
Tulsa, OK


"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module
into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from
that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that
appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts
and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with
an
address from my Outlook contacts and a return address. Does
someone
have
a
program that will help automate this? I just print it out on
regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook
Contacts.
Anyway
to do that?






  #13   Report Post  
Posted to microsoft.public.word.docmanagement
chaucersmom chaucersmom is offline
external usenet poster
 
Posts: 15
Default Shipping Label Design

Yea, Doug, I'm almost there! This is a great program for me.

After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)

Interestingly, when I saved the "label" which I made with your program, it
suggested as a name for the document, the name of the person for whom I was
making the label, even though that name wasn't visible in the document! The
same thing happened when I began with the "company", that is it suggested to
save it as the company name. But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it as
the company name.

I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope as
follows:

5 Main Street
Cocoa, VA 24544

I am so close to debugging this that I hope you can help. Using Office and
Outlook 2007.





"Doug Robbins - Word MVP" wrote:

The code should run without any changes to the Security Settings.

The box that you see containing the First and Last Name, should not really
appear but it does because when testing I had inserted a line of code

MsgBox cname

You can delete that if you do not want it.

If your template was saved as a .dotx, you will need to replace this line of
code

Set olabel = oWord.Documents.Add("ShippingLabel.dot")

with

Set olabel = oWord.Documents.Add("ShippingLabel.dotx")



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Doug,

Thanks for your patience with my Shipping Label project and my ineptitude!

The "Make Shipping Label" button on the toolbar wouldn't run the program.
So I ran the Macro from the Macro menu and the error message I got was:
"The
Macros in this project are disabled."

I went to the Trust Center, Macro Security in Outlook. The box checked
was the second one -- warnings for unsigned macros. Then I went to the
Trust
Center in Word and checked the box Trust Access to VBA project model.
Now
when I click on the Make Shipping Label button, a small box appears on the
Contacts screen with the First and Last name of the contact and that's all
that happens. MS Word doesn't open.

I am using Word 2007 and Outlook 2007. I saved my templates file as a
.dotx
file. Any suggestions?


"Doug Robbins - Word MVP" wrote:

You have missed this part of my instructions:

While in the Visual Basic Editor, select References from the Tools menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Thanks Doug for your response. Even though your solution was probably
much
more complicated than I have ever tried, your directions were
fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping label"
on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label,
rather
than using Ctr F9. I doubt, though, that this caused the error since it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module
into
the
Project1 item that will appear there and into that module, paste the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on the
Toolbar
at the top of the screen and select Customize, then on the Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's address to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from
that
template in Word with the details of the selected contact appearing in
it.

If you want, in the Contacts screeen in Outlook, if you right click on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that
appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
I can't get labels to work on Word 2007. I've looked at the posts
and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time with
an
address from my Outlook contacts and a return address. Does
someone
have
a
program that will help automate this? I just print it out on
regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook
Contacts.
Anyway
to do that?






  #14   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Shipping Label Design

You don't want to put any actual data into a template (.dotx), because
then it will appear in every document, i.e., label, that you base on
that template!

On Jul 30, 2:34*pm, chaucersmom
wrote:
Yea, Doug, I'm almost there! This is a great program for me. *

After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. *(Just had the Docvariable lines that were in the template.)

Interestingly, when I saved the "label" which I made with your program, it
suggested as a name for the document, the name of the person for whom I was
making the label, even though that name wasn't visible in the document! The
same thing happened when I began with the "company", that is it suggested to
save it as the company name. * *But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it as
the company name.

I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope as
follows:

5 Main Street
Cocoa, VA 24544

I am so close to debugging this that I hope you can help. *Using Office and
Outlook 2007.

  #15   Report Post  
Posted to microsoft.public.word.docmanagement
chaucersmom chaucersmom is offline
external usenet poster
 
Posts: 15
Default Shipping Label Design

Thanks Peter for allowing me to clarify what I meant:

I only put the {Docvariable} in the template. The program was supposed to
replace the bracketed codes with the appropriate information from my Outlook
contacts into a shipping label.

The document that I saved was the result of running the program -- it was to
be a shipping label with the name and address replacing the Docvariables. It
was based on a template that I had created. I didn't save it over the
Template. The way I discovered the strange behavior, that is, the info
lurking in the background, was simply an accident.



"Peter T. Daniels" wrote:

You don't want to put any actual data into a template (.dotx), because
then it will appear in every document, i.e., label, that you base on
that template!

On Jul 30, 2:34 pm, chaucersmom
wrote:
Yea, Doug, I'm almost there! This is a great program for me.

After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)

Interestingly, when I saved the "label" which I made with your program, it
suggested as a name for the document, the name of the person for whom I was
making the label, even though that name wasn't visible in the document! The
same thing happened when I began with the "company", that is it suggested to
save it as the company name. But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it as
the company name.

I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope as
follows:

5 Main Street
Cocoa, VA 24544

I am so close to debugging this that I hope you can help. Using Office and
Outlook 2007.




  #16   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

It sounds like you need to toggle off the display of the field codes by
using Alt+F9.

When you enter contact details in Outlook, it divides up the individual
parts of the address into the following components:

FullName
CompanyName
BusinessAddressStreet
BusinessAddressCity
BusinessAddressState
BusinessAddressPostalCode
BusinessAddressCountry

Sometimes, if it is not clear how the parts should be divided, it will pop
up a dialog box asking you to confirm the choice that it has made.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Yea, Doug, I'm almost there! This is a great program for me.

After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)

Interestingly, when I saved the "label" which I made with your program, it
suggested as a name for the document, the name of the person for whom I
was
making the label, even though that name wasn't visible in the document!
The
same thing happened when I began with the "company", that is it suggested
to
save it as the company name. But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it
as
the company name.

I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope as
follows:

5 Main Street
Cocoa, VA 24544

I am so close to debugging this that I hope you can help. Using Office
and
Outlook 2007.





"Doug Robbins - Word MVP" wrote:

The code should run without any changes to the Security Settings.

The box that you see containing the First and Last Name, should not
really
appear but it does because when testing I had inserted a line of code

MsgBox cname

You can delete that if you do not want it.

If your template was saved as a .dotx, you will need to replace this line
of
code

Set olabel = oWord.Documents.Add("ShippingLabel.dot")

with

Set olabel = oWord.Documents.Add("ShippingLabel.dotx")



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Doug,

Thanks for your patience with my Shipping Label project and my
ineptitude!

The "Make Shipping Label" button on the toolbar wouldn't run the
program.
So I ran the Macro from the Macro menu and the error message I got was:
"The
Macros in this project are disabled."

I went to the Trust Center, Macro Security in Outlook. The box
checked
was the second one -- warnings for unsigned macros. Then I went to the
Trust
Center in Word and checked the box Trust Access to VBA project model.
Now
when I click on the Make Shipping Label button, a small box appears on
the
Contacts screen with the First and Last name of the contact and that's
all
that happens. MS Word doesn't open.

I am using Word 2007 and Outlook 2007. I saved my templates file as a
.dotx
file. Any suggestions?


"Doug Robbins - Word MVP" wrote:

You have missed this part of my instructions:

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object
Library
(##
will vary depending upon the version of Word that you are using.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Thanks Doug for your response. Even though your solution was
probably
much
more complicated than I have ever tried, your directions were
fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping
label"
on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label,
rather
than using Ctr F9. I doubt, though, that this caused the error since
it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it
will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module
into
the
Project1 item that will appear there and into that module, paste
the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem =
Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object
Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on
the
Toolbar
at the top of the screen and select Customize, then on the Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a
name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the
existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's address
to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from
that
template in Word with the details of the selected contact appearing
in
it.

If you want, in the Contacts screeen in Outlook, if you right click
on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that
appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in
message
...
I can't get labels to work on Word 2007. I've looked at the posts
and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time
with
an
address from my Outlook contacts and a return address. Does
someone
have
a
program that will help automate this? I just print it out on
regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook
Contacts.
Anyway
to do that?







  #17   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

The code is using Documents.Add to create a new document from the template.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Peter T. Daniels" wrote in message
...
You don't want to put any actual data into a template (.dotx), because
then it will appear in every document, i.e., label, that you base on
that template!

On Jul 30, 2:34 pm, chaucersmom
wrote:
Yea, Doug, I'm almost there! This is a great program for me.

After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)

Interestingly, when I saved the "label" which I made with your program, it
suggested as a name for the document, the name of the person for whom I
was
making the label, even though that name wasn't visible in the document!
The
same thing happened when I began with the "company", that is it suggested
to
save it as the company name. But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it
as
the company name.

I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope as
follows:

5 Main Street
Cocoa, VA 24544

I am so close to debugging this that I hope you can help. Using Office and
Outlook 2007.


  #18   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

Have you tried updating the fields in the document? The code however should
do that.

I do not know anything about Worldox, but it could be interfering somewhere.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in message
...
Yes, the codes are there.


"Doug Robbins - Word MVP" wrote:

If you press Alt+F9 in the Word window that opens, do you see the field
codes in the document?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in
message
...
Yes.


"Doug Robbins - Word MVP" wrote:

Do you have the DOCVARIABLE fields in your template?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"gr8auntieokie" wrote in
message
...
Doug, I decided to see if _I_ could create your macro in Outlook,
too.
The
macro in Outlook is okay, but when I click on the contact name and
then
click
on the "MakeShippingLabel" button in my custom toolbar, a Word
window
opens
but nothing else happens. (If it matters, I did modify the macro so
it
would
search for the name of my Word template, changing the Word template
from
"ShippingLabel.dot" to "MakeLabl.dot.")

Our firm stores all our documents, templates, etc. in Worldox (a
document
management software) and I'm wondering if the path through Worldox
to
my
template might be what's stopping the Outlook macro from working.
Any
ideas??

Thanks.
Cyndie Browning
Software Support Specialist
GableGotwals
Tulsa, OK


"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it
will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module
into
the
Project1 item that will appear there and into that module, paste
the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem =
Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object
Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on
the
Toolbar
at the top of the screen and select Customize, then on the Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a
name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the
existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's address
to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from
that
template in Word with the details of the selected contact appearing
in
it.

If you want, in the Contacts screeen in Outlook, if you right click
on
the
toolbar and select customize and then right click on the
Project1.MakeShippingLabel button, you can change the Name that
appears
on
the button from Project1.MakeShippingLabel to just Shipping Label.



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in
message
...
I can't get labels to work on Word 2007. I've looked at the posts
and
help
items, but it seems much too complicated for what I want to do.

All I want to do is to print out one shipping label at a time
with
an
address from my Outlook contacts and a return address. Does
someone
have
a
program that will help automate this? I just print it out on
regular
paper,
not on an Avery sheet.

Alternatively, I can easily design the label as I've done in
WordPerfect,
but I want to be able to choose the address from my Outlook
Contacts.
Anyway
to do that?







  #19   Report Post  
Posted to microsoft.public.word.docmanagement
chaucersmom chaucersmom is offline
external usenet poster
 
Posts: 15
Default Shipping Label Design

You were absolutely right! I forgot to do the Alt f9 after I had entered the
variables. The program now works, but only IF I have a business address to
make a shipping label for. Most of my ship to addresses are HOME addresses.
How should I change the variables in the program to look for a HOME address.

I must say, I've learned a great deal from your posts to me! Thanks.

"Doug Robbins - Word MVP" wrote:

It sounds like you need to toggle off the display of the field codes by
using Alt+F9.

When you enter contact details in Outlook, it divides up the individual
parts of the address into the following components:

FullName
CompanyName
BusinessAddressStreet
BusinessAddressCity
BusinessAddressState
BusinessAddressPostalCode
BusinessAddressCountry

Sometimes, if it is not clear how the parts should be divided, it will pop
up a dialog box asking you to confirm the choice that it has made.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Yea, Doug, I'm almost there! This is a great program for me.

After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)

Interestingly, when I saved the "label" which I made with your program, it
suggested as a name for the document, the name of the person for whom I
was
making the label, even though that name wasn't visible in the document!
The
same thing happened when I began with the "company", that is it suggested
to
save it as the company name. But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it
as
the company name.

I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope as
follows:

5 Main Street
Cocoa, VA 24544

I am so close to debugging this that I hope you can help. Using Office
and
Outlook 2007.





"Doug Robbins - Word MVP" wrote:

The code should run without any changes to the Security Settings.

The box that you see containing the First and Last Name, should not
really
appear but it does because when testing I had inserted a line of code

MsgBox cname

You can delete that if you do not want it.

If your template was saved as a .dotx, you will need to replace this line
of
code

Set olabel = oWord.Documents.Add("ShippingLabel.dot")

with

Set olabel = oWord.Documents.Add("ShippingLabel.dotx")



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Doug,

Thanks for your patience with my Shipping Label project and my
ineptitude!

The "Make Shipping Label" button on the toolbar wouldn't run the
program.
So I ran the Macro from the Macro menu and the error message I got was:
"The
Macros in this project are disabled."

I went to the Trust Center, Macro Security in Outlook. The box
checked
was the second one -- warnings for unsigned macros. Then I went to the
Trust
Center in Word and checked the box Trust Access to VBA project model.
Now
when I click on the Make Shipping Label button, a small box appears on
the
Contacts screen with the First and Last name of the contact and that's
all
that happens. MS Word doesn't open.

I am using Word 2007 and Outlook 2007. I saved my templates file as a
.dotx
file. Any suggestions?


"Doug Robbins - Word MVP" wrote:

You have missed this part of my instructions:

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object
Library
(##
will vary depending upon the version of Word that you are using.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Thanks Doug for your response. Even though your solution was
probably
much
more complicated than I have ever tried, your directions were
fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping
label"
on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the label,
rather
than using Ctr F9. I doubt, though, that this caused the error since
it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it
will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a module
into
the
Project1 item that will appear there and into that module, paste
the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem =
Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object
Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on
the
Toolbar
at the top of the screen and select Customize, then on the Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a
name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the
existing
one.

Now in Word, create a new template that you save with the name of
ShippingLabel and in that template, setup the Return Address as you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's address
to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created from
that
template in Word with the details of the selected contact appearing
in
it.

  #20   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Shipping Label Design

Note her second paragraph, where she says "the template opened" but
"the variables weren't filled in," as if she expected them to be. I
suppose she means that she opened a document based on the template
(such as by double-clicking on the template's name).

On Jul 30, 4:59*pm, "Doug Robbins - Word MVP"
wrote:
The code is using Documents.Add to create a new document from the template.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Peter T. Daniels" wrote in ...
You don't want to put any actual data into a template (.dotx), because
then it will appear in every document, i.e., label, that you base on
that template!

On Jul 30, 2:34 pm, chaucersmom



wrote:
Yea, Doug, I'm almost there! This is a great program for me.


After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)


Interestingly, when I saved the "label" which I made with your program, it
suggested as a name for the document, the name of the person for whom I
was
making the label, even though that name wasn't visible in the document!
The
same thing happened when I began with the "company", that is it suggested
to
save it as the company name. But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it
as
the company name.


I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope as
follows:


5 Main Street
Cocoa, VA 24544


I am so close to debugging this that I hope you can help. Using Office and
Outlook 2007.- Hide quoted text -


- Show quoted text -




  #21   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

No, it is all done by the code. See my first response in this thread.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Peter T. Daniels" wrote in message
...
Note her second paragraph, where she says "the template opened" but
"the variables weren't filled in," as if she expected them to be. I
suppose she means that she opened a document based on the template
(such as by double-clicking on the template's name).

On Jul 30, 4:59 pm, "Doug Robbins - Word MVP"
wrote:
The code is using Documents.Add to create a new document from the
template.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Peter T. Daniels" wrote in
...
You don't want to put any actual data into a template (.dotx), because
then it will appear in every document, i.e., label, that you base on
that template!

On Jul 30, 2:34 pm, chaucersmom



wrote:
Yea, Doug, I'm almost there! This is a great program for me.


After changing the name of the file in the program to .dotx, my template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)


Interestingly, when I saved the "label" which I made with your program,
it
suggested as a name for the document, the name of the person for whom I
was
making the label, even though that name wasn't visible in the document!
The
same thing happened when I began with the "company", that is it
suggested
to
save it as the company name. But if I eliminated both the name and the
company from the template and then made a label, it suggested to save it
as
the company name.


I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope
as
follows:


5 Main Street
Cocoa, VA 24544


I am so close to debugging this that I hope you can help. Using Office
and
Outlook 2007.- Hide quoted text -


- Show quoted text -


  #22   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Shipping Label Design

In the code in the Outlook Visual Basic Editor, replace

cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry

with

cname = .FullName
ccompany = .CompanyName
cstreet = .HomeAddressStreet
ccity = .HomeAddressCity
cstate = .HomeAddressState
czip = .HomeAddressPostalCode
ccountry = .HomeAddressCountry


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
You were absolutely right! I forgot to do the Alt f9 after I had entered
the
variables. The program now works, but only IF I have a business address
to
make a shipping label for. Most of my ship to addresses are HOME
addresses.
How should I change the variables in the program to look for a HOME
address.

I must say, I've learned a great deal from your posts to me! Thanks.

"Doug Robbins - Word MVP" wrote:

It sounds like you need to toggle off the display of the field codes by
using Alt+F9.

When you enter contact details in Outlook, it divides up the individual
parts of the address into the following components:

FullName
CompanyName
BusinessAddressStreet
BusinessAddressCity
BusinessAddressState
BusinessAddressPostalCode
BusinessAddressCountry

Sometimes, if it is not clear how the parts should be divided, it will
pop
up a dialog box asking you to confirm the choice that it has made.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Yea, Doug, I'm almost there! This is a great program for me.

After changing the name of the file in the program to .dotx, my
template
opened in Word, but the variables weren't filled in with the name and
address. (Just had the Docvariable lines that were in the template.)

Interestingly, when I saved the "label" which I made with your program,
it
suggested as a name for the document, the name of the person for whom I
was
making the label, even though that name wasn't visible in the document!
The
same thing happened when I began with the "company", that is it
suggested
to
save it as the company name. But if I eliminated both the name and
the
company from the template and then made a label, it suggested to save
it
as
the company name.

I think I'm a little confused as to how the program "knows" what the
separate parts of the address (city, state, zip, etc) since I enter the
address in the address box as I would if I were addressing an envelope
as
follows:

5 Main Street
Cocoa, VA 24544

I am so close to debugging this that I hope you can help. Using Office
and
Outlook 2007.





"Doug Robbins - Word MVP" wrote:

The code should run without any changes to the Security Settings.

The box that you see containing the First and Last Name, should not
really
appear but it does because when testing I had inserted a line of code

MsgBox cname

You can delete that if you do not want it.

If your template was saved as a .dotx, you will need to replace this
line
of
code

Set olabel = oWord.Documents.Add("ShippingLabel.dot")

with

Set olabel = oWord.Documents.Add("ShippingLabel.dotx")



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in message
...
Doug,

Thanks for your patience with my Shipping Label project and my
ineptitude!

The "Make Shipping Label" button on the toolbar wouldn't run the
program.
So I ran the Macro from the Macro menu and the error message I got
was:
"The
Macros in this project are disabled."

I went to the Trust Center, Macro Security in Outlook. The box
checked
was the second one -- warnings for unsigned macros. Then I went to
the
Trust
Center in Word and checked the box Trust Access to VBA project
model.
Now
when I click on the Make Shipping Label button, a small box appears
on
the
Contacts screen with the First and Last name of the contact and
that's
all
that happens. MS Word doesn't open.

I am using Word 2007 and Outlook 2007. I saved my templates file as
a
.dotx
file. Any suggestions?


"Doug Robbins - Word MVP" wrote:

You have missed this part of my instructions:

While in the Visual Basic Editor, select References from the Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object
Library
(##
will vary depending upon the version of Word that you are using.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"chaucersmom" wrote in
message
...
Thanks Doug for your response. Even though your solution was
probably
much
more complicated than I have ever tried, your directions were
fantastic.
I
have never even made a template before today!

Sadly, after I completed everything, I clicked on the "shipping
label"
on
the toolbar and an error message came up: "User-defined type not
defined."
It highlighted "Dim oWord As Word.Application"

When I made the template, I simply pasted your lines into the
label,
rather
than using Ctr F9. I doubt, though, that this caused the error
since
it
didn't get as far as opening Word.

Any suggestions for fixing the "bug?"

"Doug Robbins - Word MVP" wrote:

This may be too complicated for you, but if you do set it up, it
will
do
all
of the work for you.

First, in Outlook, open the Visual Basic Editor and insert a
module
into
the
Project1 item that will appear there and into that module, paste
the
following code:

Sub MakeShippingLabel()
Dim objitem As Object
Dim cname As String
Dim ccompany As String
Dim cstreet As String
Dim ccity As String
Dim cstate As String
Dim czip As String
Dim ccountry As String
Dim oWord As Word.Application
Dim WordNotRunning As Boolean
Dim olabel As Document
Set objitem = GetCurrentItem()
MsgBox objitem.FullName
If objitem.Class = olContact Then
With objitem
cname = .FullName
ccompany = .CompanyName
cstreet = .BusinessAddressStreet
ccity = .BusinessAddressCity
cstate = .BusinessAddressState
czip = .BusinessAddressPostalCode
ccountry = .BusinessAddressCountry
End With
End If
Set objitem = Nothing
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word was not running
Set oWord = New Word.Application
WordNotRunning = True
End If
oWord.Visible = True
oWord.Activate
Set olabel = oWord.Documents.Add("ShippingLabel.dot")
With olabel
.Variables("varname").Value = cname
.Variables("varcompany").Value = ccompany
.Variables("varstreet").Value = cstreet
.Variables("varcity").Value = ccity
.Variables("varstate").Value = cstate
.Variables("varzip").Value = czip
.Variables("varcountry").Value = ccountry
.Range.Fields.Update
End With

If WordNotRunning Then
oWord.Quit
End If
Set oWord = Nothing
Set olabel = Nothing
End Sub
Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem =
Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

While in the Visual Basic Editor, select References from the
Tools
menu
and
then place a check mark against the Microsoft Word ##.0 Object
Library
(##
will vary depending upon the version of Word that you are using.

Next, with the Contacts screen active in Outlook, right click on
the
Toolbar
at the top of the screen and select Customize, then on the
Toolbars
tab
of
the Customize dialog, click on New then give the new Toolbar a
name,
say
Label Maker and click on OK. Then go to the Commands tab of the
Customize
dialog and select the macros Category and you should see an item
"MakeShippingLabel" Click on it and Drag it onto the new
toolbar.
Then
drag that toolbar up to the top of the screen adjacent to the
existing
one.

Now in Word, create a new template that you save with the name
of
ShippingLabel and in that template, setup the Return Address as
you
want
it,
and using Ctrl+F9 for each pair of field delimiters, set up the
following
fields in the configuration that you want the addressee's
address
to
appear

{ DOCVARIABLE varname}
{ DOCVARIABLE varcompany}
{ DOCVARIABLE varstreet}
{ DOCVARIABLE varcity} { DOCVARIABLE varstate} { DOCVARIABLE
varzip}
{ DOCVARIABLE varcountry}

Press Alt+F9 to toggle off the display of the field codes and
then
save
and
close the template.

Now, when you select a contact in Outlook and click on the
Project1.MakeShippingLabel button, a document will be created
from
that
template in Word with the details of the selected contact
appearing
in
it.


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shipping label template 2"x4" Jay Microsoft Word Help 8 March 4th 10 06:27 PM
How can I set up a shipping label to accomadate a preprinted logo Dmags Mailmerge 1 June 30th 09 03:53 PM
shipping address and a return address on 1 label???! climbergirl17 Microsoft Word Help 1 August 9th 08 05:47 AM
template for shipping label Elaine Microsoft Word Help 1 September 27th 05 03:08 AM
how do i design a custom cd label template bill halliwell Microsoft Word Help 4 August 2nd 05 04:30 PM


All times are GMT +1. The time now is 01:22 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"