Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Houston, Texas, USA
    Thanked 0 Times in 0 Posts

    Can I open a form from within a form?

    I am using Outlook 98 and want to know if I can open a form, then using a button open up a second form.

    This is what I use to shell out and I wonder if I can change this to open up a second form.
    'Call Extra2
    Sub cmdExtra2_click()
    Set objWSHShell = CreateObject("WScript.Shell")
    end sub

  2. #2

    Re: Can I open a form from within a form?

    If you are just trying to create a new form from within a form you can do that pretty easily.

    sub cmdNewForm_Click()

    'This line will create a new mail message from within a form

    Set newItem = Application.CreateItem(olMailItem)

    'This line will add a custom form to a particular folder and open it.

    Set newForm = olFolder.Items.Add("IPM.Note.FORMNAME")

    End Sub

    To get the folder object (olFolder), use the following line of code and function.

    Set olFolder = OpenMAPIFolder("Public FoldersAll Public FoldersFolderName")

    Function OpenMAPIFolder(byVal strPath)
    Dim objFldr
    Dim strDir
    Dim strName
    Dim i
    On Error Resume Next
    If Left(strPath, Len("")) = "" Then
    strPath = Mid(strPath, Len("") + 1)
    Set objFldr = Application.ActiveExplorer.CurrentFolder
    end if
    While strPath <> ""
    i = Instr(strPath, "")
    If i Then
    strDir = Left(strPath, i-1)
    strPath = Mid(strPath, i + Len(""))
    strDir = strPath
    strPath = ""
    end if
    If objFldr is Nothing then
    Set objFldr = Application.GetNameSpace("MAPI").Folders(strDir)
    On Error Goto 0
    ****Set objFldr = objFldr.Folders(strDir)****
    end if
    Set OpenMAPIFolder = objFldr
    End Function

    You can also set the olFolder object to one of the default folders as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts