Can't get code to put data into current folder

G

Guest

Sue,
Am trying to adapt your Listing 24.4 to my needs to make objContact entries
into what is selected as Current Folder. Program runs and works but all
objContact entries show up in the default Contacts folder rather than the
selected current folder. With Watches set during Debut I can see that the
Current Folder is getting selected OK, and the code is creating
objContacts...just not in the current folder. Can you take a look at this
partila listng of the code and tell me what is wrong. The Watch on
objCurrentFolder in line 5 shows for sure it is at the current folder I want
the objContacts to go to, but they go into the default Contacts folder
instead:
Set objWB = objExcel.Workbooks.Add("C:\ExcelDL.xls")
Set objWS = objWB.Worksheets(1)
Set objRange = objWS.Range("test")
Set objApp = CreateObject("Outlook.Application")
Set objCurrentFolder = objApp.ActiveExplorer.CurrentFolder
If Not objCurrentFolder Is Nothing Then
intRowCount = objRange.Rows.Count
If intRowCount > 0 Then
For I = 1 To intRowCount
Set objContact = objApp.CreateItem(olContactItem)
With objContact
.FullName = objRange.Cells(I, 1)
.Email1AddressType = objRange.Cells(I, 3)
.Email1Address = objRange.Cells(I, 2)
.Save
End With
Next
End If
End If
 
S

Sue Mosher [MVP-Outlook]

CreateItem always puts items in the default folder. Use objCurrentFolder.Items.Add instead.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Sue,
Was just coming back to post another message to tell you I had already found
the answer to my previous posting on page 262 of your book, when I got your
posting notification at the same time. Should have looked harder in your
book....but I'm learning a lot from your book and should be less of a pest as
time continues. Bear with me. I think I am a testimony to your book that
it can teach a almost non-experienced programmer (Fotran, Basic, and Pascal
were my last experience years ago) how to work in VBA ;>)

BTW, one help would be a CD-ROM with electronic .pdf version of your book
provided with the book so searches could be done electronically....that is
the case with Jim Boyce's book and it is extremely helpful. Recognize that
Amazon gave me access to online search of your manuscript, but it is slow and
the user interface is a pain. Maybe something to consider if your publisher
would go for it in your next edition or next book.
 
S

Sue Mosher [MVP-Outlook]

Thanks for the suggestion. I'll pass it along, but I've never seen Digital Press package a CD with any of the books in this series.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


John E. said:
Sue,
Was just coming back to post another message to tell you I had already found
the answer to my previous posting on page 262 of your book, when I got your
posting notification at the same time. Should have looked harder in your
book....but I'm learning a lot from your book and should be less of a pest as
time continues. Bear with me. I think I am a testimony to your book that
it can teach a almost non-experienced programmer (Fotran, Basic, and Pascal
were my last experience years ago) how to work in VBA ;>)

BTW, one help would be a CD-ROM with electronic .pdf version of your book
provided with the book so searches could be done electronically....that is
the case with Jim Boyce's book and it is extremely helpful. Recognize that
Amazon gave me access to online search of your manuscript, but it is slow and
the user interface is a pain. Maybe something to consider if your publisher
would go for it in your next edition or next book.
 

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