#1   Report Post  
Posted to microsoft.public.word.docmanagement
donwb donwb is offline
external usenet poster
 
Posts: 2
Default Default values

Office 2003 on Win XP
In Word, to print a label from Outlook's address book, I do the following.
Select Tools / Letters & Mailings / Envelopes & Labels
Then click the Address Book Icon
Then click OK on the Outlook "Profile Name"
This brings up the Address Book "Select Name" dialog box.
That's all fine and as expected.
However, under the "Name" heading in the Address Book "Select Name" dialog
box,
the "Full Name" field from the Outlook address book is shown as the default.
I would prefer it to be the "Last Name" field from the address book instead.
Can this (default) setting be changed and if so how?
donwb


  #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 Default values

I think that if what you want to do is change the way the names are
displayed, you will need to use a userform that is populated with the
Outlook Contact Details.

Here is the code that you would use in the Initialize event of the userform
to populate a combobox on the form with Outlook Contact details:

Private Sub UserForm_Initialize()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim x As Integer
If Not DisplayStatusBar Then
DisplayStatusBar = True
End If
StatusBar = "Please Wait..."
x = 0
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder _
(olFolderContacts).Items
With Me.cboContactList
.AddItem (oItm.LastName & ", " & oItm.FirstName)
.Column(1, x) = oItm.BusinessAddress
.Column(2, x) = oItm.BusinessAddressCity
.Column(3, x) = oItm.BusinessAddressState & ", " &
oItm.BusinessAddressPostalCode
' .Column(4, x) = oItm.BusinessAddressPostalCode
End With
x = x + 1
Next oItm
StatusBar = ""
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
Dim MyArray() As Variant, i As Integer, j As Integer, m As Integer, n As
Integer, target As Document, newtable As Table, myitem As Range
'Load client data into MyArray
MyArray = cboContactList.List()
' Create a new document containing a table
Application.ScreenUpdating = False
Set target = Documents.Add
Set newtable = target.Tables.Add(Range:=target.Range(0, 0),
numrows:=cboContactList.ListCount, NumColumns:=5)
' Populate the cells of the table with the contents of the array
For i = 1 To cboContactList.ListCount
For j = 1 To 4
newtable.Cell(i, j).Range.InsertBefore MyArray(i - 1, j - 1)
Next j
Next i
' sort the table
newtable.Sort ExcludeHeader:=False ', FieldNumber:="Column 1",
SortFieldType:=wdSortFieldText, SortOrder:=wdSortOrderAscending
i = newtable.Rows.Count
' Get the number of columns in the table of client details
j = 4
' Set the number of columns in the Listbox to match
' the number of columns in the table of client details
cboContactList.ColumnCount = 4
' Define an array to be loaded with the client data
Dim NewArray() As Variant
'Load client data into MyArray
ReDim NewArray(i, j)
For n = 0 To j - 1
For m = 0 To i - 1
Set myitem = newtable.Cell(m + 1, n + 1).Range
myitem.End = myitem.End - 1
NewArray(m, n) = myitem.Text
Next m
Next n
' Load data into ListBox1
cboContactList.List() = NewArray
target.Close wdDoNotSaveChanges
Application.ScreenUpdating = True

End Sub

If you have not come across userforms, See the article "How to create a
Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
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

"donwb" wrote in message
...
Office 2003 on Win XP
In Word, to print a label from Outlook's address book, I do the following.
Select Tools / Letters & Mailings / Envelopes & Labels
Then click the Address Book Icon
Then click OK on the Outlook "Profile Name"
This brings up the Address Book "Select Name" dialog box.
That's all fine and as expected.
However, under the "Name" heading in the Address Book "Select Name" dialog
box,
the "Full Name" field from the Outlook address book is shown as the
default.
I would prefer it to be the "Last Name" field from the address book
instead.
Can this (default) setting be changed and if so how?
donwb




  #3   Report Post  
Posted to microsoft.public.word.docmanagement
donwb donwb is offline
external usenet poster
 
Posts: 2
Default Default values

Hi Doug
Many thanks for the input, but that's a bit above me.
I thought it would be possible to simply change the default setting for
Envelopes & Labels in Word.
donwb

"Doug Robbins - Word MVP" wrote in message
...
I think that if what you want to do is change the way the names are
displayed, you will need to use a userform that is populated with the
Outlook Contact Details.

Here is the code that you would use in the Initialize event of the
userform to populate a combobox on the form with Outlook Contact details:

Private Sub UserForm_Initialize()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim x As Integer
If Not DisplayStatusBar Then
DisplayStatusBar = True
End If
StatusBar = "Please Wait..."
x = 0
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder _
(olFolderContacts).Items
With Me.cboContactList
.AddItem (oItm.LastName & ", " & oItm.FirstName)
.Column(1, x) = oItm.BusinessAddress
.Column(2, x) = oItm.BusinessAddressCity
.Column(3, x) = oItm.BusinessAddressState & ", " &
oItm.BusinessAddressPostalCode
' .Column(4, x) = oItm.BusinessAddressPostalCode
End With
x = x + 1
Next oItm
StatusBar = ""
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
Dim MyArray() As Variant, i As Integer, j As Integer, m As Integer, n
As Integer, target As Document, newtable As Table, myitem As Range
'Load client data into MyArray
MyArray = cboContactList.List()
' Create a new document containing a table
Application.ScreenUpdating = False
Set target = Documents.Add
Set newtable = target.Tables.Add(Range:=target.Range(0, 0),
numrows:=cboContactList.ListCount, NumColumns:=5)
' Populate the cells of the table with the contents of the array
For i = 1 To cboContactList.ListCount
For j = 1 To 4
newtable.Cell(i, j).Range.InsertBefore MyArray(i - 1, j - 1)
Next j
Next i
' sort the table
newtable.Sort ExcludeHeader:=False ', FieldNumber:="Column 1",
SortFieldType:=wdSortFieldText, SortOrder:=wdSortOrderAscending
i = newtable.Rows.Count
' Get the number of columns in the table of client details
j = 4
' Set the number of columns in the Listbox to match
' the number of columns in the table of client details
cboContactList.ColumnCount = 4
' Define an array to be loaded with the client data
Dim NewArray() As Variant
'Load client data into MyArray
ReDim NewArray(i, j)
For n = 0 To j - 1
For m = 0 To i - 1
Set myitem = newtable.Cell(m + 1, n + 1).Range
myitem.End = myitem.End - 1
NewArray(m, n) = myitem.Text
Next m
Next n
' Load data into ListBox1
cboContactList.List() = NewArray
target.Close wdDoNotSaveChanges
Application.ScreenUpdating = True

End Sub

If you have not come across userforms, See the article "How to create a
Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
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

"donwb" wrote in message
...
Office 2003 on Win XP
In Word, to print a label from Outlook's address book, I do the
following.
Select Tools / Letters & Mailings / Envelopes & Labels
Then click the Address Book Icon
Then click OK on the Outlook "Profile Name"
This brings up the Address Book "Select Name" dialog box.
That's all fine and as expected.
However, under the "Name" heading in the Address Book "Select Name"
dialog box,
the "Full Name" field from the Outlook address book is shown as the
default.
I would prefer it to be the "Last Name" field from the address book
instead.
Can this (default) setting be changed and if so how?
donwb






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
Assign Default values to bookmarks Rafi Mailmerge 1 December 11th 06 06:23 PM
setting default values for tables [email protected] Formatting Long Documents 1 August 4th 06 12:22 AM
changing table default values PAL Microsoft Word Help 0 June 8th 06 02:29 PM
Default field values from AD profile info?? Steven Heinz Mailmerge 2 May 9th 06 08:17 AM
How can I reset my styles and formatting to default values? cem Microsoft Word Help 2 August 3rd 05 07:51 PM


All times are GMT +1. The time now is 01:50 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"