Creating Task Views Methodically

Status
Not open for further replies.
T

tomthedev

All, I have been trying to create views through code unsuccessfully through

several examples. I can run code and get at views xml where the view has

been created by the Outlook GUI. Is there a straightforward way the xml

generated can be used to create views on different Outlook

installations/desktops? If so, are there

any samples of adding a view with xml dynamically? I have seen a couple

with DOM and LoadXML method, but have not gotten the views to add in the

first place.

Thank you!

tom the developer
 
I've installed custom views on machines as part of my addin run, but I

haven't done any dynamic creation of the XML.

I've always used canned XML files or resources that I've created and

debugged first.

There's no reason why the view XML can't be created on the fly and then

assigned as the current view or one of the available views for a folder or

folder type, but you have to make sure any view XML created that way will

actually work.

If these are canned views that don't depend on something on the target

system to be custom then why go through all that work? Why not just use

canned XML that you know will work?

Most of the sample view XML stuff I've run into has been at

www.outlookcode.com.

"tomthedev" <tjwhitehouse@hotmail.com> wrote in message

news:E10B4116-9D57-42AB-9734-2D2A35D8F403@microsoft.com...

> All, I have been trying to create views through code unsuccessfully
> through
> several examples. I can run code and get at views xml where the view has
> been created by the Outlook GUI. Is there a straightforward way the xml
> generated can be used to create views on different Outlook
> installations/desktops? If so, are there
> any samples of adding a view with xml dynamically? I have seen a couple
> with DOM and LoadXML method, but have not gotten the views to add in the
> first place.
> Thank you!
> > tom the developer
 
Ken,

Thank you very much for your reply.

In concept, can I create the xml in the GUI, save it out or look at it, then

reproduce the xml in code and add it in outlook through the code?

I would think this could be the case. The only part I question is being

able to add the view in code in a stable manner. I saw an example for

views.add and load.xml, but could get neither to work. Perhaps if I get back

to basics have a sample that works(even it is very simple)?

Your help is greatly appreciated!

tom the developer
wrote:


> I've installed custom views on machines as part of my addin run, but I
> haven't done any dynamic creation of the XML.

> I've always used canned XML files or resources that I've created and
> debugged first.

> There's no reason why the view XML can't be created on the fly and then
> assigned as the current view or one of the available views for a folder or
> folder type, but you have to make sure any view XML created that way will
> actually work.

> If these are canned views that don't depend on something on the target
> system to be custom then why go through all that work? Why not just use
> canned XML that you know will work?

> Most of the sample view XML stuff I've run into has been at
> www.outlookcode.com.

> >

>

> "tomthedev" <tjwhitehouse@hotmail.com> wrote in message
> news:E10B4116-9D57-42AB-9734-2D2A35D8F403@microsoft.com...
> > All, I have been trying to create views through code unsuccessfully
> > through
> > several examples. I can run code and get at views xml where the view has
> > been created by the Outlook GUI. Is there a straightforward way the xml
> > generated can be used to create views on different Outlook
> > installations/desktops? If so, are there
> > any samples of adding a view with xml dynamically? I have seen a couple
> > with DOM and LoadXML method, but have not gotten the views to add in the
> > first place.
> > Thank you!
> > > > tom the developer


>
 
What I usually do is to set up a view in the UI as close to what I want as

possible. Then I grab that view XML and modify it by hand (or code) to add

whatever else I want there. In that way for example I can add a column for a

MAPI property I've added that isn't in UserProperties.

Once that's done I can persist the XML as a string resource or a file and

use it. Certainly you can use XML coding and the DOM to set up properly

formed view XML, the end result would be the same as long as the XML is well

formed for the view schema.

At runtime I'd add my view XML to the MAPIFolder.Views collection either on

the fly when handling a button click or an Explorer folder change event with

whatever save options I wanted. Then I'd set the CurrentView to that view

and save it and apply it. It seems to work OK for me.

"tomthedev" <tjwhitehouse@hotmail.com> wrote in message

news:9A20D66B-9FBD-41C0-BCD9-460529E0ED82@microsoft.com...
> Ken,
> Thank you very much for your reply.

> In concept, can I create the xml in the GUI, save it out or look at it,
> then
> reproduce the xml in code and add it in outlook through the code?
> I would think this could be the case. The only part I question is being
> able to add the view in code in a stable manner. I saw an example for
> views.add and load.xml, but could get neither to work. Perhaps if I get
> back
> to basics have a sample that works(even it is very simple)?

> Your help is greatly appreciated!
> > tom the developer
 
Ken, that is really insightful. Thanks again!

When you add in the view, how can this be done? Must it be an Add-In

(whether COM or .Net)

or is an automation object in VBScript possible where Outlook is not opened?

Regards,

tom the developer
wrote:


> What I usually do is to set up a view in the UI as close to what I want as
> possible. Then I grab that view XML and modify it by hand (or code) to add
> whatever else I want there. In that way for example I can add a column for a
> MAPI property I've added that isn't in UserProperties.

> Once that's done I can persist the XML as a string resource or a file and
> use it. Certainly you can use XML coding and the DOM to set up properly
> formed view XML, the end result would be the same as long as the XML is well
> formed for the view schema.

> At runtime I'd add my view XML to the MAPIFolder.Views collection either on
> the fly when handling a button click or an Explorer folder change event with
> whatever save options I wanted. Then I'd set the CurrentView to that view
> and save it and apply it. It seems to work OK for me.

> >

>

> "tomthedev" <tjwhitehouse@hotmail.com> wrote in message
> news:9A20D66B-9FBD-41C0-BCD9-460529E0ED82@microsoft.com...
> > Ken,
> > Thank you very much for your reply.
> > In concept, can I create the xml in the GUI, save it out or look at it,
> > then
> > reproduce the xml in code and add it in outlook through the code?
> > I would think this could be the case. The only part I question is being
> > able to add the view in code in a stable manner. I saw an example for
> > views.add and load.xml, but could get neither to work. Perhaps if I get
> > back
> > to basics have a sample that works(even it is very simple)?
> > Your help is greatly appreciated!
> > > > tom the developer


>
 
Any language that supports COM can be used. But to work with Outlook it has

to be opened, no matter what language you're using.

"tomthedev" <tjwhitehouse@hotmail.com> wrote in message

news:150D6A77-5490-49A9-BCEE-BB87EFECEDA9@microsoft.com...

> Ken, that is really insightful. Thanks again!
> When you add in the view, how can this be done? Must it be an Add-In
> (whether COM or .Net)
> or is an automation object in VBScript possible where Outlook is not
> opened?
> Regards,

> > tom the developer
 
Here is a sub I am trying to use to modify a view's XML property. It doesn't

work but I get no errors. The only thing I can infer is the XML is being

rejected (withoiut an error raised), but the only editing I did was to the

name description fields to be displayed. The text editor I used change some

of the indent spacing in hte XML code, but I don't know if it changed EOF

etc. Is there an MS XML test program to validate View.XML coding?

Private Sub XMLView()

Dim fso, aFile

Dim newView As String

Set fso = CreateObject("Scripting.FileSystemObject")

Set aFile = fso_OpenTextFile("Q:\_Tools\Courts\CourtViewTest.txt")

newView = aFile.Readall

aFile.Close

Dim objViews As Outlook.Views

Dim objView As Outlook.View

Set objViews = Application.ActiveExplorer.CurrentFolder.Views

Set objView = objViews.Item("Court View Test")

If objView Is Nothing Then

Set objView = objViews.Add("Court View Test", olCardView,

olViewSaveOptionThisFolderEveryone)

End If

objView.XML = newView

objView.Save

objView.Apply

objViews("Court View Test").XML = newView

objViews("Court View Test").Save

objViews("Court View Test").Apply

MsgBox objViews("Court View Test").XML

MsgBox Application.ActiveExplorer.CurrentView.XML

End Sub
 
I should have added I opened the text file in MS Word but had no Outlook View

schema with which to validate it.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
G Event when creating task from mailitem Outlook VBA and Custom Forms 2
L Creating a Task from Email and Attaching Original Email Outlook VBA and Custom Forms 6
Wotme Creating a Outlook task in Excel Using Outlook 7
J Text color when creating a new Task is not consistent Using Outlook 1
B Creating a new TASK using VFP9.0 Outlook VBA and Custom Forms 2
Y Creating a Task with VBScript Outlook VBA and Custom Forms 14
G Creating Macro to scrape emails from calendar invite body Outlook VBA and Custom Forms 6
S Custom Contact card - need help creating one Outlook VBA and Custom Forms 1
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
T Outlook creating unwanted tasks in Tasks and Todo from emails Using Outlook 1
Fozzie Bear Outlook 2016 Creating a shared local Contacts folder Using Outlook 2
R Creating a user defined function Outlook VBA and Custom Forms 3
M Creating an RSS Feed **FROM** Outlook 2013 Calendar. Using Outlook 5
O How to prevent CC from showing when creating a new mail? Using Outlook 1
N Creating a button or link to a form in the Organizational Forms Library Outlook VBA and Custom Forms 3
B Creating an email with the list of tasks Outlook VBA and Custom Forms 0
L Creating drafts when I thought I was sending Using Outlook 1
R Would creating a new profile cause Outlook to download all the old mails from the server? Using Outlook 1
A Creating Progress Bar or Status Bar Update Outlook VBA and Custom Forms 0
T Outlook creating a folder named: "Unwanted" Using Outlook 3
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
Liza Creating a rule in outlook to filter messages Using Outlook 0
A Are categories still recommended for creating local distribution lists? Using Outlook 3
S Creating Email - Selecting Pre-Defined Text Using Outlook 2
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
M Creating Outlook Appointments from Excel Cells Outlook VBA and Custom Forms 1
N Creating New Profile Using Outlook 0
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5
M creating email from contact file = 3 emails in To field Using Outlook 3
P Recover / Extract Rules from standalone PST file creating RWZ file Using Outlook 2
A Creating an outlook rule to forward an email with a specific message Using Outlook 1
I Creating meeting invite with disabled tentative button Outlook VBA and Custom Forms 5
E Creating email templates for organizational use Using Outlook 0
N Creating or changing the main new mail message template in Outlook 2010 Using Outlook 2
D Creating custom view with VBA Outlook VBA and Custom Forms 2
J Outlook creating unwanted rule on its own Using Outlook 1
R Creating a Room Mailbox with Exchange Online Outlook VBA and Custom Forms 0
A Creating a rule on “Deleted items” folder Using Outlook 1
CMG73 Creating templates with predefined subject and CC Using Outlook 1
G Creating Contact Sub Folders Using Outlook 2
Rupert Dragwater creating gmail account in Outlook 2013 Using Outlook 7
nathandavies Creating a Select Case for a directory of folders Outlook VBA and Custom Forms 1
2 creating custom stationery Using Outlook 2
A Help creating macro for conditional formatting settings Using Outlook 8
Fozzie Bear Creating Custom Meeting Form Outlook VBA and Custom Forms 6
U Creating a (This computer only) folder within an IMAP account directory Using Outlook 1
A Creating archive rule on the clients by script/ Outlook VBA and Custom Forms 3
J Creating a URL from a message body excerpt before forwarding Using Outlook 2
B Need Help Creating Email Based on Subject w Address in Body Outlook VBA and Custom Forms 1

Similar threads

Back
Top