Can't get Remove method to work 
Author Message
 Can't get Remove method to work

I am using AddStore to add a PST to my namespace. When I want to remove it,
I get an error. Here is my code:

Set myNameSpace = Application.GetNameSpace("MAPI")
myNameSpace.AddStore("c:\test.pst")
'  The following loads my new PST root folder into the variable myFolder so
I can display some things about it...just for info...will be cut when the
program goes live
Set myFolder = myNameSpace.Folders.GetLast
msgbox myFolder.name & vbcrlf & vbcrlf & myFolder.storeid & vbcrlf & vbcrlf
& myFolder.entryID & vbcrlf & vbcrlf & myNameSpace.Folders.count
'  Here I just loop through to see what I have under my namespace
for intLoop = 1 to myNameSpace.Folders.Count
    msgbox "I am Folder " & intLoop & ". My name is: " &
myNameSpace.Folders(intLoop).Name
next
myNameSpace.Folders.Remove(myNameSpace.Folders.Count)

I have tried replacing the index w/an actual number. I have tried it w/ and
without the parenthesis. I have tried receiving a return value to a
variable. Nothing works. In the documentation, the Remove variable applies
to Folder Collections. Is there something here I am missing?

--
Regards,
Paul

<><><><><><><><><><><><><><><><><><><><>
Source Imaging, LLC.
Paul Engel, President
Certified Document Imaging Architech (CDIA)
Summation Certified Trainer (SCT)

Voice: 859-255-5222
Fax: 859-514-1705
www.source-imaging.com
<><><><><><><><><><><><><><><><><><><><>



Wed, 09 Mar 2005 04:25:45 GMT  
 Can't get Remove method to work
Never mind. I found the RemoveStore method and have figured out how to use
it from the XP documentation. In case you were wondering:

Sub RemovePST()

    Dim objName As NameSpace
    Dim objFolder As MAPIFolder

    Set objName = Application.GetNamespace("MAPI")
    Set objFolder = objName.Folders.Item("Personal Folders")
    objName.RemoveStore objFolder

End Sub
The key is to point the method to the folder object representing the root of
your target Store.

Paul

Quote:
> I am using AddStore to add a PST to my namespace. When I want to remove
it,
> I get an error. Here is my code:

> Set myNameSpace = Application.GetNameSpace("MAPI")
> myNameSpace.AddStore("c:\test.pst")
> '  The following loads my new PST root folder into the variable myFolder
so
> I can display some things about it...just for info...will be cut when the
> program goes live
> Set myFolder = myNameSpace.Folders.GetLast
> msgbox myFolder.name & vbcrlf & vbcrlf & myFolder.storeid & vbcrlf &
vbcrlf
> & myFolder.entryID & vbcrlf & vbcrlf & myNameSpace.Folders.count
> '  Here I just loop through to see what I have under my namespace
> for intLoop = 1 to myNameSpace.Folders.Count
>     msgbox "I am Folder " & intLoop & ". My name is: " &
> myNameSpace.Folders(intLoop).Name
> next
> myNameSpace.Folders.Remove(myNameSpace.Folders.Count)

> I have tried replacing the index w/an actual number. I have tried it w/
and
> without the parenthesis. I have tried receiving a return value to a
> variable. Nothing works. In the documentation, the Remove variable applies
> to Folder Collections. Is there something here I am missing?

> --
> Regards,
> Paul

> <><><><><><><><><><><><><><><><><><><><>
> Source Imaging, LLC.
> Paul Engel, President
> Certified Document Imaging Architech (CDIA)
> Summation Certified Trainer (SCT)

> Voice: 859-255-5222
> Fax: 859-514-1705
> www.source-imaging.com
> <><><><><><><><><><><><><><><><><><><><>



Wed, 09 Mar 2005 04:51:16 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. 'Canned' data in VB program

2. col.Remove and col.Add won't work back-to-back

3. Remove Interface Methods from class methods

4. Seek Method isn't working...

5. recordset.edit method won't work (error 3197)

6. TransferDatabase method doen't work for modules

7. Sort() method -- can't get it to work

8. Select method doesn't work properly

9. function doesn't work as a method...

10. close method on RegistryKey.OpenRemoteBaseKey doesn't seem to work

11. Button.Focus() method doesn't work (sometimes)

12. ActiveX Control - Line Method won't work in VBScript

 

 
Powered by phpBB® Forum Software