PC Review


Reply
Thread Tools Rate Thread

Default values

 
 
donwb
Guest
Posts: n/a
 
      30th Mar 2008
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 With Quote
 
 
 
 
Doug Robbins - Word MVP
Guest
Posts: n/a
 
      30th Mar 2008
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" <(E-Mail Removed)> wrote in message
news:uMFv%(E-Mail Removed)...
> 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 With Quote
 
donwb
Guest
Posts: n/a
 
      31st Mar 2008
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:uMFv%(E-Mail Removed)...
>> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table fields:- Setting default values to be based on other field values Rob W Microsoft Access 3 20th Feb 2008 08:51 PM
default values Jean-Paul De Winter Microsoft Excel Discussion 8 13th Feb 2007 11:26 PM
Default values in .Default user Shell Folders ? Michel S. Windows XP Help 2 19th Jul 2005 07:52 PM
Default values from one table, entered values in another =?Utf-8?B?bGFzZXIwMjkxMA==?= Microsoft Access Forms 2 21st Jun 2005 10:01 PM
Default values? Lovelock, David Microsoft Excel Misc 2 26th Nov 2003 12:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:48 AM.