Results 1 to 6 of 6

Thread: [RESOLVED] How to Open Published Outlook Form through Word

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Resolved [RESOLVED] How to Open Published Outlook Form through Word

    I am using a shared Outlook Calendar, and in previous instances we created Outlook Forms which are saved offline for the user to fill in and it then populate the online shared calendar, the below code works fine and dandy with that set-up, but this new form has vb code that activates a combo box that lists members of staff via Excel. This form and function doesn't work offline, so the only working form is the published one, which can be generated by the "ctrl - N"

    Is there a way to grab the published form with VB and macro it into a button for users to use?

    Code:
    Sub KeyTextCreate()
    
    On Error GoTo ErrorHandler
       
     'Sets the folder in which to post the Custom Form (public folders)
       Set ol = New Outlook.Application
        Set olns = ol.GetNamespace("MAPI")
        Set myFolder1 = olns.Folders("Public Folders")
        Set myFolder2 = myFolder1.Folders("All Public Folders")
        Set myFolder3 = myFolder2.Folders("All Local Folders")
        Set myFolder4 = myFolder3.Folders("All HQ Departments")
        Set myFolder5 = myFolder4.Folders("DLS")
        Set myFolder6 = myFolder5.Folders("Calendars")
        Set myfolderref = myFolder6.Folders("KeyTexts")
     
        
        'Creates item based on template in the above folder, i.e. myFolderRef
        Set myOlApp = CreateObject("Outlook.Application")
    '   Dim myitem As Outlook.PostItem
            
        Set myitem = myOlApp.CreateItem("K:\Databases\Daily Lists\ClaimsAvailability.oft", myfolderref)
        myitem.Display
    
        Set ol = Nothing
        Set olns = Nothing
        Set myFolder1 = Nothing
        Set myFolder2 = Nothing
        Set myFolder3 = Nothing
        Set myFolder4 = Nothing
        Set myFolder5 = Nothing
        Set myFolder6 = Nothing
        Set myfolderref = Nothing
        Set myOlApp = Nothing
        Set myitem = Nothing
    
        Exit Sub
    
    ErrorHandler:
    MsgBox "Can not create item - Try later"
    On Error GoTo ENDNOW
        Set ol = Nothing
        Set olns = Nothing
        Set myFolder1 = Nothing
        Set myFolder2 = Nothing
        Set myFolder3 = Nothing
        Set myFolder4 = Nothing
        Set myFolder5 = Nothing
        Set myFolder6 = Nothing
        Set myfolderref = Nothing
        Set myOlApp = Nothing
        Set myitem = Nothing
    ENDNOW:
    End Sub
    This is the code in the form which doesn't work offline / unpublished

    Code:
    Function Item_Open()
    
    set objPage = Item.GetInspector.ModifiedFormPages("Key Texts")
    set objControl1 = objPage.Controls("cboBorrowerName")
    set objControl2 = objPage.Controls("cboPassedTo")
    
    dim Liste_oe
    dim name_oe
    
    set objExcel = Item.Application.CreateObject("Excel.Application")
    objExcel.Workbooks.Open("K:\Databases\ComboBoxListOfLawyers.xls")
    set objExcelBook = objExcel.ActiveWorkbook
    set objExcelSheets = objExcelBook.Worksheets
    set objExcelSheet = objExcelBook.Sheets(1)
    
    For i = 1 to 44
    Liste_oe = objExcelSheet.Cells(i,1).value
    objControl1.Additem Liste_oe
    objControl2.Additem Liste_oe
    next
    
    objExcelBook.close
    objExcel.quit
    
    End Function
    Last edited by Kubull; Oct 9th, 2008 at 10:15 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width