copying a custom view from a public folder and distributing programatically

Not open for further replies.


I am probably making this way more complicated than it needs to be. I know little about vba.

I am trying to piece together snippets of code to get the result. In a nutshell, I have created a custom view and assigned it to a particular public folder.

I want to be able to create a macro that a user can run, to copy that view in the public folder into their outlook and let the view be used for all mail folders.

The name of the Public Folder is "Public Folders\All Public Folders\VorysViews"

The ViewDriver sub and CreateView Function work if I use the original

Set objViews = objName.GetDefaultFolder(FolderType:=cnstFolderName).Views

but not with what I have been trying

Set objViews = GetFolder("Public Folders\All Public Folders\VorysViews").


I have been unsuccessful getting objViews to be the views in "Public Folders\All Public Folders\VorysViews"

The other Function "GetFolder" is where I went off on a tangent because I don't think I need to return just the final folder name. I just need to copy the views from "Public Folders\All Public Folders\VorysViews" and then save the view for all mail and post folders.

I'm sure I'm overlooking the obvious. Leading me in the right direction would be really helpful.

I bought "Microsoft Outlook Programming" but don't have the 2007 version yet.

Sub ViewDriver() 
'Calls the CreateView function to return a view. 
Dim objView As View 
Set objView = CreateView(strName:="Main Inbox Table_bymacro", cnstFolderName:=olFolderInbox, cnstViewType:=olTableView) 
'MsgBox "cnstFolderName is " & cnstFolderName 

If objView Is Nothing Then 
MsgBox "The view was not created." 
'MsgBox "The view: " & objFolder.Name & " is failing badly." 
'MsgBox "objview is " & objView.Name 
MsgBox "The view: " & objView.Name & " was created sucessfully." 
End If 
End Sub 
Function CreateView(ByVal strName As String, ByVal cnstFolderName As OlDefaultFolders, ByVal cnstViewType As OlViewType) As View 
'If succesful, returns a new view. 
Dim olApp As Outlook.Application 
Dim objName As NameSpace 
Dim objViews As Views 
MsgBox "cnstFolderName is " & cnstFolderName 
On Error Resume Next 
Set olApp = Outlook.Application 
Set objName = olApp.GetNamespace(Type:="MAPI") 
'Set objViews = objName.GetDefaultFolder(FolderType:=cnstFolderName).Views 
Set objViews = GetFolder("Public Folders\All Public Folders\VorysViews").Views 
'Set objFolder =  GetFolder("Public Folders\All Public Folders\Company\Sales") 
'Create the new view. 
Set CreateView = objViews.Add(Name:=strName, ViewType:=cnstViewType, 
End Function 
'The above SaveOption will save the view to all folders of this type 
Public Function GetFolder(strFolderPath As String) As MAPIFolder 
' strFolderPath needs to be something like 
'   "Public Folders\All Public Folders\Company\Sales" or 
'   "Personal Folders\Inbox\My Folder" 
Dim objApp As Outlook.Application 
Dim objNS As Outlook.NameSpace 
Dim colFolders As Outlook.Folders 
Dim objFolder As Outlook.MAPIFolder 
Dim arrFolders() As String 
Dim I As Long 
On Error Resume Next 
strFolderPath = Replace(strFolderPath, "/", "\") 
arrFolders() = Split(strFolderPath, "\") 
Set objApp = Application 
Set objNS = objApp.GetNamespace("MAPI") 
Set objFolder = objNS.Folders.Item(arrFolders(0)) 
If Not objFolder Is Nothing Then 
For I = 1 To UBound(arrFolders) 
Set colFolders = objFolder.Folders 
Set objFolder = Nothing 
Set objFolder = colFolders.Item(arrFolders(I)) 

If objFolder Is Nothing Then 
Exit For 

End If 
End If 
Set GetFolder = objFolder 
MsgBox "GetFolder is " & objFolder.Name 
MsgBox "objFolder is " & GetFolder.Name 
Set colFolders = Nothing 
Set objNS = Nothing 
Set objApp = Nothing 
End Function
Last edited by a moderator:

Ken Slovak - [MVP - Outlook]

Are we to assume you are using Outlook 2003 at the moment?

Dim pub As Outlook.MAPIFolder

Set pub =


Get the view from this:

Set oView = pub.Views.Item("whateverTheViewNameIs")

Before saving the view at the target folder set the SaveOption property to

Last edited by a moderator:


Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Hi I look for the same possibility in OL 2010
Not open for further replies.
Thread starter Similar threads Forum Replies Date
B Copying data between atbs in a custom form Outlook VBA and Custom Forms 4
R VBA for copying sent email to current folder under a shared mailbox Outlook VBA and Custom Forms 17
E Copying the whole e-mail body into excel Outlook VBA and Custom Forms 0
E Copying data from e-mail attachement to EXCEL file via macro Outlook VBA and Custom Forms 38
T Copying Outlook Account Setup For Desktop App Using Outlook 5
J Outlook - 2013 - Error msg when copying folders from Online Archives to another user's mailbox Using Outlook 0
Thiago Manzano Copying E-mails to a folder on HD Using Outlook 1
Diane Poremsky Mark Sent Items as Read After Copying with a Rule New Articles 0
crazyboy Copying BCM database from backed up mounted image to new drive BCM (Business Contact Manager) 2
oliv- Prevent copying shared contacts Outlook VBA and Custom Forms 5
Paul Butticaz Copying Contacts from SharePoint List (connected to Outlook) to another Conacts folder Using Outlook 1
K Outlook 2010 Not responding after IMAP folder deletion or copying. Using Outlook 2
Mary B Outlook 2013: Rule for copying new email to folder & marking that copy as read Using Outlook 1
S Calendar items are not being uploaded to after copying Using accounts in Outlook 1
P open reminders missing after copying outlook pst file Using Outlook 2
L Copying Emails using drag and drop Using Outlook 2
O New to Outlook 2013, dealing with copying vs. moving sent items Using Outlook 0
S Recover messages that disappeared when copying to folder Using Outlook 1
S Copying multiple messages to folders and keeping date/time detail Using Outlook 1
D Copying POP3 folders from Inbox to IMAP Inbox in Outlook 2003 Using Outlook 0
M Copying setups for mutiple users Using Outlook 2
T Location and simple copying of emails and settings, OL 2010 and Win 7 64bit. Using Outlook 3
A Copying additional contact fields when chosing "Contact from the same company" Using Outlook 5
A Copying cc email addresses to Excel - does not copy the <> Using Outlook 1
S Search Indexing (Copying Folders) Using Outlook 0
I copying messages from inbox to folder outside outlook Using Outlook 2
C Copying an email. Using Outlook 1
B Moving or copying a Hotmail Folder to an external Hard Disk?____ Using Outlook 2
F copying outlook Using Outlook 3
T Copying contacts Using Outlook 3
I Copying mailboxes from Exchange 2003 to Exchange 2010 Exchange Server Administration 3
1 Error message when copying contacts from one group to another Using Outlook 2
R copying or cutting an appointment to paste it to a different date Using Outlook 1
O Copying Outlook Categories to the attachment (MS word) body in bulk. Is this possible? Using Outlook 7
J Random copying of emails in inbox and calendar appointments deleted Using Outlook 1
S How to retain "Date Sent" and "Date Received" data when copying email messages from Outlook to an Ex Using Outlook 2
E Copying multiple folders to PST Outlook VBA and Custom Forms 2
N error when copying outlook data "can not copy: the path too deep" Using Outlook 6
N Copying outlook macros between pcs Outlook VBA and Custom Forms 1
R Copying Data from Exchange to PST file Outlook VBA and Custom Forms 1
V Copying contents from one field to another field Outlook VBA and Custom Forms 6
S Custom Field Cannot Be Displayed In Views Outlook VBA and Custom Forms 2
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
F Validation on custom task form after task acceptance Outlook VBA and Custom Forms 1
K UDF with formula not showing on Calendar custom view. Outlook VBA and Custom Forms 0
S Create a clickable custom column field Outlook VBA and Custom Forms 0
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
M VbScript for Command Button on Contacts Custom Form Using Outlook 1
G Other users can't see P.2 with custom fields in Form Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
Similar threads