Re: Call a Custom Form

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Sue Mosher [MVP-Outlook] (suemvp_at_outlookcode.com)
Date: 07/22/04

  • Next message: Nac McFeegle: "Re: Osama Found Hanged is a DISGUISED VIRUS"
    Date: Thu, 22 Jul 2004 13:01:15 -0400
    
    

    Yes, I think you might want to read up on how to use custom functions. You
    shouldn't have changed the declaration statement for the GetFolder()
    function. You would call it in code with a statement like this:

        Set objFolder = GetFolder("Public Folders\All Public
    Folders\Company\Sales")

    -- 
    Sue Mosher, Outlook MVP
    Author of
         Microsoft Outlook Programming - Jumpstart for
         Administrators, Power Users, and Developers
         http://www.outlookcode.com/jumpstart.aspx
    "Tim" <Tim_member@newsguy.com> wrote in message
    news:cdoigs0146g@drn.newsguy.com...
    > Sue,
    > It appears that I have a basic syntax understanding:
    >
    > Function GetFolder("Public Folders\All Public Folders")
    >   ' folder path needs to be something like
    >   '   "Public Folders\All Public Folders\Company\Sales"
    >   Dim aFolders
    >   Dim fldr
    >   Dim i
    >   Dim objNS
    >
    > The above code segment gives me the error : Compile error: Expected
    Identifier.
    > When I enter the path to the folder.
    >
    > I also have this code that will call the custom form, but will not save to
    the
    > public folder.  I assume I need to call the folder with the GetFolder
    command in
    > order for this to work, instead of GetDefaultFolder
    >
    > Public Sub OpenForm()
    >     Dim objOutlook ‘As Outlook.Application
    >     Dim objNS ‘As Outlook.NameSpace
    >     Dim objFolder ‘As Outlook.MAPIFolder
    >     Dim objForm ‘As Outlook.ContactItem
    >     Dim objItems ‘As Outlook.Items
    >
    >     On Error Resume Next
    >
    >     ' Instantiate an Outlook Application object.
    >     Set objOutlook = CreateObject("Outlook.Application")
    >
    >     Set objNS = objOutlook.GetNamespace("MAPI")
    >     Set objFolder = objNS.GetDefaultFolder(olFolderTasks)
    >     Set objItems = objFolder.Items
    >     Set objForm = objItems.Add("IPM.Task.XXXX")
    >     objForm.Display
    >
    >     Set objNS = Nothing
    >     Set objFolder = Nothing
    >     Set objItems = Nothing
    >     Set objForm = Nothing
    > Set objOutlook = Nothing
    > End Sub
    >
    > Thanks
    >
    > Tim
    >
    >
    >
    >
    > In article <eYJx3d#bEHA.556@tk2msftngp13.phx.gbl>, Sue Mosher
    [MVP-Outlook]" <
    >
    > suemvp@outlookcode.com> says...
    > >
    > >I think that should work. What happens when you step through your code in
    > >the debugger?
    > >
    > >-- 
    > >Sue Mosher, Outlook MVP
    > >Author of
    > >     Microsoft Outlook Programming - Jumpstart for
    > >     Administrators, Power Users, and Developers
    > >     http://www.outlookcode.com/jumpstart.aspx
    > >
    > >
    > >"Tim" <Tim_member@newsguy.com> wrote in message
    > >news:cdoab60c2n@drn.newsguy.com...
    > >> Sue,
    > >> I did look at the code on your page and notices that you mention that
    if
    > >the
    > >> string has "?" in the folder name modifications are needed.  What about
    an
    > >"&" I
    > >> am supecting this is one of the reasons I had problems with your
    example.
    > >>
    > >>
    > >> In article <u3KfXh2bEHA.2944@TK2MSFTNGP11.phx.gbl>, Sue Mosher
    > >[MVP-Outlook]"
    > >> <suemvp@outlookcode.com> says...
    > >> >
    > >> >To create a new instance of a custom form programmatically, use the
    Add
    > >> >method on the target folder's Items collection. If it's a message
    form,
    > >you
    > >> >can use the Drafts folder as the target. If the target is a default
    > >folder,
    > >> >you can use the Namespace.GetDefaultFolder method to return it as a
    > >> >MAPIFolder object. Otherwise, you can use the code at
    > >> >http://www.outlookcode.com/d/code/getfolder.htm to walk the folder
    > >hierarchy
    > >> >and return the MAPIFolder corresponding to a given path string.
    > >> >
    > >> >"Tim" <Tim_member@newsguy.com> wrote in message
    > >> >news:cdm9s10arl@drn.newsguy.com...
    > >> >> Hi,
    > >> >> I am trying to duplicate a custom form using VBA and have the code
    > >> >automatically
    > >> >> copy the subject to the new form.  My goal is to create a “Master
    task”
    > >> >with sub
    > >> >> tasks,  I am using the following code to call a new task with a
    command
    > >> >button:
    > >> >>
    > >> >>
    > >> >> Sub CommandButton1_Click()
    > >> >>       Dim MyItem
    > >> >> Set MyItem = Application.CreateItem(3)
    > >> >> MyItem.Subject = "Test Task"
    > >> >> MyItem.Save
    > >> >> MyItem.Display
    > >> >> End Sub
    > >> >>
    > >> >> My question is even when this code is run from the first custom
    form; I
    > >> >get a
    > >> >> generic task and not my custom form.  How do I call the custom form
    and
    > >> >copy the
    > >> >> subject line from the currently opened form?
    > >
    > >
    >
    

  • Next message: Nac McFeegle: "Re: Osama Found Hanged is a DISGUISED VIRUS"
  • Quantcast