If you would like to make some extra cash for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html
Want to get up to speed on the latest Visual Basic programming? Includes Visual Basic 6 and Visual InterDev 6. Check out our training programs at http://www.codeoftheweek.com/vbtraining.html
In this issue we discuss how to publish forms designed in Outlook.
If you have any questions about using this module, let us know at email@example.com
The basPublish module contains a single routine that calls several methods within the Outlook object model. The most important two are CreateItemFromTemplate and PublishForm. The CreateItemFromTemplate allows you to take a OFT file (which is created in the Outlook design form mode by selecting Save As...) and publish it to a personal or organizational library for use within Outlook.
Using this module is most useful for forms which you want to make accessible to more than one person. Once you publish a form to the personal library it is available from the Tools / Forms / Choose Form option. It will also be available by using code similiar to the following:
Set oApplication = CreateObject("Outlook.Application") Set mynamespace = oApplication.GetNamespace("MAPI") Set formsfolder = mynamespace.GetDefaultFolder(6) ' inbox Set myitem = formsfolder.Items.Add("IPM.Note.Test Form") myitem.Display
Public Sub PublishForm(sTemplateName As String, eWhichRegistry As OlFormRegistry)
This method will publish the form specified by sTemplateName into the registry specified by eWhichRegistry. Currently only olOrganizationRegistry and olPersonalRegistry is supported. You must specify the full path and filename to sTemplateName or the routine will raise an error 53 (file not found). Any other errors will also be raised (such as if Outlook can not be started) so make sure you have your error handlers defined appropriately.
The below sample shows how to publish an Outlook form we have created called c:\forms\test.oft into the Personal Forms Library.
PublishForm "c:\forms\test.oft", olPersonalRegistry
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0110.html
If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html