myNameSpace difficulties 
Author Message
 myNameSpace difficulties

Set fd = myNameSpace.Folders(myNameSpace.CurrentUser.Name & "'s
Folders").Folders("JEC - Calendar")

This line of Visual Basic code reconizes what user is in Outlook.  It works
as long as the user's name does not end with "s".
However if the user's name does end in "s" it doesn't work because the
program doesn't reconize "s's".
For example it would be Dennis' Folders instead of Dennis's Folders.  How do
we get the program to reconize this?
Should we use an if statement?



Sat, 09 Nov 2002 03:00:00 GMT  
 myNameSpace difficulties
Brian,

Use a bit of code to check:

strUser = myNameSpace.CurrentUser.Name
If UCase(Right(strUser,1)) = "S" Then
    Set fd = myNameSpace.Folders(strUser & "' Folders").Folders("JEC - Calendar")
Else
    Set fd = myNameSpace.Folders(strUser & "'s Folders").Folders("JEC - Calendar")
EndIf

Steve

Quote:

> Set fd = myNameSpace.Folders(myNameSpace.CurrentUser.Name & "'s
> Folders").Folders("JEC - Calendar")

> This line of Visual Basic code reconizes what user is in Outlook.  It works
> as long as the user's name does not end with "s".
> However if the user's name does end in "s" it doesn't work because the
> program doesn't reconize "s's".
> For example it would be Dennis' Folders instead of Dennis's Folders.  How do
> we get the program to reconize this?
> Should we use an if statement?



Sat, 09 Nov 2002 03:00:00 GMT  
 myNameSpace difficulties
Why involve the user name at all? This is a more generic method, using the
Parent folder of the Inbox:

    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
    Set objTopFolder = objInbox.Parent
    Set fd = objTopFolder.Folders("JEC - Calendar")

--
Sue Mosher
Author of
  "Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
  "Microsoft Outlook 2000 E-mail and Fax Guide"

Outlook and Exchange solutions at http://www.slipstick.com


Quote:
> Set fd = myNameSpace.Folders(myNameSpace.CurrentUser.Name & "'s
> Folders").Folders("JEC - Calendar")

> This line of Visual Basic code reconizes what user is in Outlook.  It
works
> as long as the user's name does not end with "s".
> However if the user's name does end in "s" it doesn't work because the
> program doesn't reconize "s's".
> For example it would be Dennis' Folders instead of Dennis's Folders.  How
do
> we get the program to reconize this?
> Should we use an if statement?



Sun, 10 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. myNameSpace.logoff delai

2. VB TransferText Command difficulties

3. LIKE operator difficulty

4. Avg difficulties

5. Difficulties with 2 "@"-signs in messagebox

6. Create Appointment difficulty

7. RTF - inserting text - difficulties with RTF code stripped by Outlook

8. NameSpace difficulties

9. Command Bar & Button Difficulties

10. Difficulties with bookmarks in a word template

11. Difficulty assessing state of field

12. Difficulty assessing state of field - Attention Doug Robbins

 

 
Powered by phpBB® Forum Software