ANGanley MCSD

I have created the following code to generate an email.

When the email is generated I want to be able to use the users own theme.

Private Sub CreateMailItem()

Dim application As New Microsoft.Office.Interop.Outlook.Application

Dim mailItem1 As Microsoft.Office.Interop.Outlook.MailItem = _

TryCast(application.CreateItem( _

Microsoft.Office.Interop.Outlook.OlItemType.olMailItem), _

Microsoft.Office.Interop.Outlook.MailItem)

mailItem1.To = txt_email.Text

mailItem1.Subject = cmb_enquiry.SelectedText & "Enquiry"

mailItem1.Body = txt_enquiryhelper.Text

mailItem1.Display()

End Sub

Any ideas thanks.




Re: Visual Studio Tools for Office Stationery & Fonts - Themes

Ji Zhou – MSFT

Hi,

You should use WordEditor to get a Word document and then use the ApplyTheme() method of the document. C# codes are like:

Code Block

Outlook.MailItem mail = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) as Outlook.MailItem;

mail.To = "somebody@microsoft.com";

mail.Subject = "Test";

mail.Body = "This is a test";

mail.Display(missing);

Word.Document doc = mail.GetInspector.WordEditor as Word.Document;

doc.ApplyTheme("EDGE 111");

About ApplyTheme() method, you can refer this link:

http://msdn2.microsoft.com/en-us/library/aa171557(office.11).aspx

Wish this helps!

Thanks

Ji






Re: Visual Studio Tools for Office Stationery & Fonts - Themes

ANGanley

Thanks for that.

I have added the following code.

Dim wrdDoc As Microsoft.Office.Interop.Word.Document

But when i try & reference the mail.GetInspector it does not appear.






Re: Visual Studio Tools for Office Stationery & Fonts - Themes

ANGanley

I've added the folowing code & it seems to work.

Dim doc As Microsoft.Office.Interop.Word.Document = CType(mailItem1.GetInspector.WordEditor, Microsoft.Office.Interop.Word.Document)

But when i use

doc.ApplyTheme("connect")

I get

The specified theme cannot be found.

Any ideas how to reference the theme i want.






Re: Visual Studio Tools for Office Stationery & Fonts - Themes

Ji Zhou – MSFT

Hi AG,

You can get a full description about the ApplyTheme() method in the link I gave above. ApplyTheme() needs a string variable to be parameter. This string consists of two parts. One is the Theme Folder Name, typically locating under “C:\Program Files\Common Files\Microsoft Shared\THEMES”. The second part of the parameter is nnn, where one n can be 1 or 0. The three-digit string indicates which theme formatting options to activate (1 to activate, 0 to deactivate). The digits correspond to the Vivid Colors, Active Graphics, and Background Image check boxes in the Theme dialog box (Theme command, Format menu). If this string is omitted, the default value for nnn is "011". So my code look like doc.ApplyTheme("EDGE 111"). And it works because EDGE is a sub folder in C:\Program Files\Common Files\Microsoft Shared\THEMES.

How did you create your theme What is its extension name

Thanks

Ji






Re: Visual Studio Tools for Office Stationery & Fonts - Themes

ANGanley

Thanks for that.

Sorry to be a pain but any ideas why option 1 works & option 2 does not.

Option1

'doc.ApplyTheme("IRIS 011")

Option2

doc.ApplyTheme("C:\Program Files\Common Files\microsoft shared\THEMES12\IRIS\IRIS.INF 011")

I am having problems if I enter the full path name.






Re: Visual Studio Tools for Office Stationery & Fonts - Themes

Ji Zhou – MSFT

Hi AG,

The string needs to be a folder’s name under C:\Program Files\Common Files\Microsoft shared\THEMES12. If you use the option 2, full path name, word will try search an unexisted folder named “C:\Program Files\Common Files\Microsoft shared\THEMES12\IRIS\IRIS.INF” in C:\Program Files\Common Files\Microsoft shared\THEMES12\

Thanks

Ji






Re: Visual Studio Tools for Office Stationery & Fonts - Themes

ANGanley

Nice1 Ji.

Thank for all your help.

AG.