I am new to trying to script with Outlook, but what I am doing is
trying to add a specific folder to the Public Folders FAVORITES. Below
is my code. When I run it, Outlook locks up...I close Outlook and I
get the error "Remote Procedure Call Failed". Any ideas?


AddToFavorites

Sub AddToFavorites()
'Adds a Public Folder to the list of favorites
Dim olapp
Dim objFolder, newfolder

set olapp = CreateObject("Outlook.Application")
set objFolder = olapp.GetNameSpace("MAPI")
Set objFolder1 = objFolder.Folders("Public Folders").Folders("All
Public Folders").Folders("Office Locations")

Set newfolder = objFolder1.AddToPFFavorites
End Sub

RE: Add to Public Folder Favorites? by RodneyD

RodneyD
Tue Mar 15 15:19:06 CST 2005

Try this:
Dim olapp As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Set olapp = New Outlook.Application
Set objFolder =
olapp.Session.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders.Item("Office Locations")
objFolder.AddToPFFavorites

"RobG3381" wrote:

> I am new to trying to script with Outlook, but what I am doing is
> trying to add a specific folder to the Public Folders FAVORITES. Below
> is my code. When I run it, Outlook locks up...I close Outlook and I
> get the error "Remote Procedure Call Failed". Any ideas?
>
>
> AddToFavorites
>
> Sub AddToFavorites()
> 'Adds a Public Folder to the list of favorites
> Dim olapp
> Dim objFolder, newfolder
>
> set olapp = CreateObject("Outlook.Application")
> set objFolder = olapp.GetNameSpace("MAPI")
> Set objFolder1 = objFolder.Folders("Public Folders").Folders("All
> Public Folders").Folders("Office Locations")
>
> Set newfolder = objFolder1.AddToPFFavorites
> End Sub
>
>

Re: Add to Public Folder Favorites? by RobG3381

RobG3381
Tue Mar 15 15:49:07 CST 2005

I actually have that also. I guess a better question...can this be
done OUTSIDE Outlook? The code you displayed I think works from within
Outlook in the macros using VBA, right? What I am trying to do is do
this from outside Outlook like in a .vbs Login script, etc... Can that
be done?