Get values of custom variables from customised contact form

G

Guest

I am trying to use the Scripting.TextStream aspect of FileSystemObject on a
customised contact form. I want every record in the contacts folder to be
exported as a .csv file at the click of a button.

I have tried instantiating the custom variables "mxzParentCompany", "Last
Name", "mxzVIP" & "BusinessAddressCity" as follows, but this only outputs the
data in the immediate record.

Sub mxzcboExportCurrentRecord_Click()

Dim fso, MyFile
Dim txtmxzParentCompany
Dim txtLastName
Dim txtmxzVIP
Dim txtBusinessAddressCity
Dim objInspector

Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile("c:\testfile.txt", True)

Set objInspector = Item.GetInspector

txtmxzParentCompany =
Item.UserProperties_("mxzParentCompany").Value
txtLastName = Item.UserProperties("Last Name").Value
txtmxzVIP = Item.UserProperties("mxzVIP").Value
txtBusinessAddressCity = Item.UserProperties_
("Business Address City").Value
'txtmxzNCRL2 = Item.UserProperties("mxzNCRL2").Value

MyFile.WriteLine(txtmxzParentCompany & " " & txtLastName & " "_ &
txtmxzVIP & " " &_ txtBusinessAddressCity & " ")

MyFile.Close

Set fso = Nothing
Set objInspector = Nothing
Set txtmxzParentCompany = Nothing
Set txtLastName = Nothing
Set txtmxzVIP = Nothing
Set txtBusinessAddressCity = Nothing

End Sub

How can I instantiate the custom variables so that they print out the above
fields from every record in my contact folder?
 
K

Ken Slovak - [MVP - Outlook]

If the folder is selected use ActiveExplorer.CurrentFolder.Items and iterate
the Items collection. Be aware that Distribution Lists may also be there so
test for the correct message class and handle any errors for DL's. If not
selected then use NameSpace.GetDefaultFolder(olFolderContacts) to get the
Contacts folder and then use its Items collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top