More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

forum 18-Dec-2018 14:18

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

    Page [ 1 2 3 4 5 6 7 8 9 10 Next >> ]  
 Outlook Form Design Printer Friendly Version
Designing custom Outlook forms and form regions and writing code for them
Topic
Sending out forms
Hello Sue,
So i can put this code on the current form we have now, and make a button that runs the code?
ANd hten if an update comes out 3 days latter, they can push the button on the form, and it will auto update?
Thanks
JOe

Sub PublishForm(strPath, strName)
    Dim objOL As Outlook.Application
    Dim objItem As Outlook.ContactItem
    Dim objFD As Outlook.FormDescription
    
    Set objOL = CreateObject("Outlook.Application")
    Set objItem = objOL.CreateItemFromTemplate(strPath)
    Set objFD = objItem.FormDescription
    With objFD
        .DisplayName = strName
        .PublishForm olPersonalRegistry
    End With
    objItem.Close olDiscard
    
    Set objFD = Nothing
    Set objItem = Nothing
    Set objOL = Nothing
End Sub
 

  10-Jun-2004  11:34
  10-Jun-2004  11:50   
Hello Sue,
This is the code i have:
form some reason i get a error but it dosent tell me where just line 374.
What i tried to do is make a "Update" button on the form, that way they can open the custom form, then hit "update" button and it will go get the latest version of the form on the network, and then publish it to there personal forms libary.
Will this work?

Sub PublishForm_Click("\\ktmsc0f4\Public\printingforms\andytest.oft", "multiform")
    Dim objOL As Outlook.Application
    Dim objItem As Outlook.ContactItem
    Dim objFD As Outlook.FormDescription
    
    Set objOL = CreateObject("Outlook.Application")
    Set objItem = objOL.CreateItemFromTemplate(strPath)
    Set objFD = objItem.FormDescription
    With objFD
        .DisplayName = strName
        .PublishForm olPersonalRegistry
    End With
    objItem.Close olDiscard
    
    Set objFD = Nothing
    Set objItem = Nothing
    Set objOL = Nothing
End Sub
  10-Jun-2004  12:06   
Oops: You can't use olPersonalRegistry olDiscard in VBSCript. Look up the literal value for that constant in the object browse.

You should be able to look at your code to determine what Line 374 is.

If this Sub is intended to be a real Click event handler, you can't pass parameters in the Sub definition. Set the values for strPath and strName in the body of the procedure instead.
  10-Jun-2004  12:23   
Hello Sue,

Ok so it should look something like this right?
HOw would the code run? if there is no button to make it run?
Im really confussed on how to make this one work.
Cause all my problems would be solved if i made a button called "update" and then click the button on the form, and it updates it self.

Sub PublishForm("\\ktmsc0f4\Public\printingforms\andytest.oft", "multiform")
    Dim strpath = "\\ktmsc0f4\Public\printingforms\andytest.oft",
    Dim strname = "multiform"
    Dim objOL As Outlook.Application
    Dim objItem As Outlook.ContactItem
    Dim objFD As Outlook.FormDescription
    
    Set objOL = CreateObject("Outlook.Application")
    Set objItem = objOL.CreateItemFromTemplate(strPath)
    Set objFD = objItem.FormDescription
    With objFD
        .DisplayName = strName
        .PublishForm olPersonalRegistry
    End With
    objItem.Close olDiscard
    
    Set objFD = Nothing
    Set objItem = Nothing
    Set objOL = Nothing
End Sub
  10-Jun-2004  12:29   
All i want to do with the code is have the user if neccacy press the "update" Button
and it published the form in there personal forms libary, and if it has to it will say "do you want to overright the exiziting file" and they can say yes.

Because i have a intranet link to where it opens the form from there personal folders.

I really wanted a way where they can just click a button on a intranet webpage that says "update" and it does the same thing, i guess its better to have it run in the form, but i will have to make more rounds of updating the forms once again.
 
  10-Jun-2004  12:42   
Approach #1:

Sub PublishForm()
    Dim strpath = "\\ktmsc0f4\Public\printingforms\andytest.oft",
    Dim strname = "multiform"
    ' etc.

Approach #2:

Sub DoUpdate
   Call PublishForm("\\ktmsc0f4\Public\printingforms\andytest.oft", "multiform")
End Sub

Sub PublishForm(strPath, strName)
     Dim objOL As Outlook.Application
    Dim objItem As Outlook.ContactItem
    Dim objFD As Outlook.FormDescription
    ' etc.
End Sub

Do you understand the difference? #2 is more flexible; you can reuse it in many diffefrent sitiuations because it doesn't set the path or the name in the body of the procedure.

See my earlier post on the need to replace olDiscard and olPersonalRegistry with the literal values, since these are Outlook constants that VBScript doesn't recognize.
 
  10-Jun-2004  12:52   
So the Approact #2 i would go something like this right:

Sub PublishForm(strPath, strName)
   Dim strpath = "\\ktmsc0f4\Public\printingforms\andytest.oft",
    Dim strname = "multiform"
     Dim objOL As Outlook.Application
    Dim objItem As Outlook.ContactItem
    Dim objFD As Outlook.FormDescription

ANd then for option #1
i can just keep the same thing i had right?
  10-Jun-2004  13:00   
Ok i put this code in my form, i created a command button called "PublishForm"

Sub DoUpdate
Call PublishForm("\\ktmsc0f4\Public\printingforms\andytest.oft", "multiform")
End Sub

Sub PublishForm(strPath, strName)
Dim objOL As Outlook.Application
Dim objItem As Outlook.ContactItem
Dim objFD As Outlook.FormDescription

    With objFD
        .DisplayName = multiform
        .PublishForm olPersonalRegistry
    End With
    objItem.Close olDiscard
    
    Set objFD = Nothing
    Set objItem = Nothing
    Set objOL = Nothing
End Sub

But the code dosent work.
:(
  10-Jun-2004  13:02   
What would I change the OlDiscard and OlPersonalRegistry to?
I looked in the object browser and it really dont understand it

Thanks
JOe
  10-Jun-2004  13:41   
Then you need to learn. Switch from <All Libraries> to Outlook to browse all Outlook objects and their properties, methods, and events. Type olDiscard into the box next to the binoculars, then click the binoculars. The search will find the constant, and at the bottom of the screen, you'll see a Const declaration which you can paste into your program.

If you don't understand constants, variables, and literal values, you might want to back up and either read the relevant information in my book or work through some of the available VBScript tutorials -- see http://www.outlookcode.com/d/vbscript.htm
 
  10-Jun-2004  14:24   
Ok i view the outlook objects but when i click on it, it gives me examples, but i dont know what im suposto put as my own or change them to, it dosent say
    Page [ 1 2 3 4 5 6 7 8 9 10 Next >> ]