VB vs VBA differences handling invites 
Author Message
 VB vs VBA differences handling invites

I wrote this function to automate the accept process on selected invites I get.

It is working fine within outlookXP. see the code below.

I tried to do the same thing from VB. I get error message "runtime error 91, object variable or with block variable not set". my last debug string says "testing the item ... class=53" which is the olMeetingRequest

Help please
thanks
David

  The VB code:
Private Sub AcceptSelectedInvites_Click()
 Dim myOlApp, myNameSpace As Object
    Dim myAddressList, myAddressEntries, myAddressEntry As Object
    Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object
    Dim myclass As Object

    Dim I, J, MyCount, response As Integer
    Dim FoundFlag As Boolean
    Dim DestinationFolderName As String

        Set myOlApp = CreateObject("Outlook.Application")
        Set myNameSpace = myOlApp.GetNamespace("MAPI")
'        Set Sel = Application.ActiveExplorer.Selection
        Set Sel = myOlApp.ActiveExplorer.Selection

        ShowIt.AddItem "Number of selected items: " & Sel.Count
        For I = 1 To Sel.Count
            ShowIt.AddItem "Testing the items... Class= " & Sel.Item(I).Class
            myclass = Sel.Item(I).Class        
            If myclass = olMeetingRequest Then
                ShowIt.AddItem "Handling the appointment ..."
                Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                Apointment.Respond olMeetingAccepted, True, False ' no dialog
                ShowIt.AddItem "Item accepted!"
            End If
        Next
End Sub

  The outlook VBA code that works
Public Sub AcceptSelectedInvites()
    Dim myOlApp, myNameSpace As Object
    Dim myAddressList, myAddressEntries, myAddressEntry As Object
    Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object

    Dim I, J, MyCount, response As Integer
    Dim FoundFlag As Boolean
    Dim DestinationFolderName As String

        Set myOlApp = CreateObject("Outlook.Application")
        Set myNameSpace = myOlApp.GetNamespace("MAPI")
        Set Sel = Application.ActiveExplorer.Selection
        For I = 1 To Sel.Count
            If Sel.Item(I).Class = olMeetingRequest Then
                Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                Apointment.Respond olMeetingAccepted, True, False ' no dialog
            End If
        Next

End Sub



Tue, 30 Nov 2004 07:40:37 GMT  
 VB vs VBA differences handling invites

Not sure if this is the problem... but in your code you have declared myclass as an object, yet later you are trying to use it as something else.


  I wrote this function to automate the accept process on selected invites I get.

  It is working fine within outlookXP. see the code below.

  I tried to do the same thing from VB. I get error message "runtime error 91, object variable or with block variable not set". my last debug string says "testing the item ... class=53" which is the olMeetingRequest

  Help please
  thanks
  David

    The VB code:
  Private Sub AcceptSelectedInvites_Click()
   Dim myOlApp, myNameSpace As Object
      Dim myAddressList, myAddressEntries, myAddressEntry As Object
      Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object
      Dim myclass As Object

      Dim I, J, MyCount, response As Integer
      Dim FoundFlag As Boolean
      Dim DestinationFolderName As String

          Set myOlApp = CreateObject("Outlook.Application")
          Set myNameSpace = myOlApp.GetNamespace("MAPI")
  '        Set Sel = Application.ActiveExplorer.Selection
          Set Sel = myOlApp.ActiveExplorer.Selection

          ShowIt.AddItem "Number of selected items: " & Sel.Count
          For I = 1 To Sel.Count
              ShowIt.AddItem "Testing the items... Class= " & Sel.Item(I).Class
              myclass = Sel.Item(I).Class        
              If myclass = olMeetingRequest Then
                  ShowIt.AddItem "Handling the appointment ..."
                  Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                  Apointment.Respond olMeetingAccepted, True, False ' no dialog
                  ShowIt.AddItem "Item accepted!"
              End If
          Next
  End Sub

    The outlook VBA code that works
  Public Sub AcceptSelectedInvites()
      Dim myOlApp, myNameSpace As Object
      Dim myAddressList, myAddressEntries, myAddressEntry As Object
      Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object

      Dim I, J, MyCount, response As Integer
      Dim FoundFlag As Boolean
      Dim DestinationFolderName As String

          Set myOlApp = CreateObject("Outlook.Application")
          Set myNameSpace = myOlApp.GetNamespace("MAPI")
          Set Sel = Application.ActiveExplorer.Selection
          For I = 1 To Sel.Count
              If Sel.Item(I).Class = olMeetingRequest Then
                  Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                  Apointment.Respond olMeetingAccepted, True, False ' no dialog
              End If
          Next

  End Sub



Thu, 02 Dec 2004 22:25:23 GMT  
 VB vs VBA differences handling invites

i think tha VB could have handled the point you mentioned

I figured out the error:
 In VB I did not have the "option explicit" statement (bad boy!) and hence all the ol*  (example the olMeetingRequest) were not defined and at run time were 0....

  How do I make VB recognize the outlook constants ???

Thanks
David


  Not sure if this is the problem... but in your code you have declared myclass as an object, yet later you are trying to use it as something else.


    I wrote this function to automate the accept process on selected invites I get.

    It is working fine within outlookXP. see the code below.

    I tried to do the same thing from VB. I get error message "runtime error 91, object variable or with block variable not set". my last debug string says "testing the item ... class=53" which is the olMeetingRequest

    Help please
    thanks
    David

      The VB code:
    Private Sub AcceptSelectedInvites_Click()
     Dim myOlApp, myNameSpace As Object
        Dim myAddressList, myAddressEntries, myAddressEntry As Object
        Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object
        Dim myclass As Object

        Dim I, J, MyCount, response As Integer
        Dim FoundFlag As Boolean
        Dim DestinationFolderName As String

            Set myOlApp = CreateObject("Outlook.Application")
            Set myNameSpace = myOlApp.GetNamespace("MAPI")
    '        Set Sel = Application.ActiveExplorer.Selection
            Set Sel = myOlApp.ActiveExplorer.Selection

            ShowIt.AddItem "Number of selected items: " & Sel.Count
            For I = 1 To Sel.Count
                ShowIt.AddItem "Testing the items... Class= " & Sel.Item(I).Class
                myclass = Sel.Item(I).Class        
                If myclass = olMeetingRequest Then
                    ShowIt.AddItem "Handling the appointment ..."
                    Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                    Apointment.Respond olMeetingAccepted, True, False ' no dialog
                    ShowIt.AddItem "Item accepted!"
                End If
            Next
    End Sub

      The outlook VBA code that works
    Public Sub AcceptSelectedInvites()
        Dim myOlApp, myNameSpace As Object
        Dim myAddressList, myAddressEntries, myAddressEntry As Object
        Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object

        Dim I, J, MyCount, response As Integer
        Dim FoundFlag As Boolean
        Dim DestinationFolderName As String

            Set myOlApp = CreateObject("Outlook.Application")
            Set myNameSpace = myOlApp.GetNamespace("MAPI")
            Set Sel = Application.ActiveExplorer.Selection
            For I = 1 To Sel.Count
                If Sel.Item(I).Class = olMeetingRequest Then
                    Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                    Apointment.Respond olMeetingAccepted, True, False ' no dialog
                End If
            Next

    End Sub



Fri, 03 Dec 2004 04:04:40 GMT  
 VB vs VBA differences handling invites

Add a reference to Microsoft Outlook via the Project | Reference menu selection.


  i think tha VB could have handled the point you mentioned

  I figured out the error:
   In VB I did not have the "option explicit" statement (bad boy!) and hence all the ol*  (example the olMeetingRequest) were not defined and at run time were 0....

    How do I make VB recognize the outlook constants ???

  Thanks
  David


    Not sure if this is the problem... but in your code you have declared myclass as an object, yet later you are trying to use it as something else.


      I wrote this function to automate the accept process on selected invites I get.

      It is working fine within outlookXP. see the code below.

      I tried to do the same thing from VB. I get error message "runtime error 91, object variable or with block variable not set". my last debug string says "testing the item ... class=53" which is the olMeetingRequest

      Help please
      thanks
      David

        The VB code:
      Private Sub AcceptSelectedInvites_Click()
       Dim myOlApp, myNameSpace As Object
          Dim myAddressList, myAddressEntries, myAddressEntry As Object
          Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object
          Dim myclass As Object

          Dim I, J, MyCount, response As Integer
          Dim FoundFlag As Boolean
          Dim DestinationFolderName As String

              Set myOlApp = CreateObject("Outlook.Application")
              Set myNameSpace = myOlApp.GetNamespace("MAPI")
      '        Set Sel = Application.ActiveExplorer.Selection
              Set Sel = myOlApp.ActiveExplorer.Selection

              ShowIt.AddItem "Number of selected items: " & Sel.Count
              For I = 1 To Sel.Count
                  ShowIt.AddItem "Testing the items... Class= " & Sel.Item(I).Class
                  myclass = Sel.Item(I).Class        
                  If myclass = olMeetingRequest Then
                      ShowIt.AddItem "Handling the appointment ..."
                      Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                      Apointment.Respond olMeetingAccepted, True, False ' no dialog
                      ShowIt.AddItem "Item accepted!"
                  End If
              Next
      End Sub

        The outlook VBA code that works
      Public Sub AcceptSelectedInvites()
          Dim myOlApp, myNameSpace As Object
          Dim myAddressList, myAddressEntries, myAddressEntry As Object
          Dim EmailAddress, UserName, Item, Sel, DestinationFolder, Apointment As Object

          Dim I, J, MyCount, response As Integer
          Dim FoundFlag As Boolean
          Dim DestinationFolderName As String

              Set myOlApp = CreateObject("Outlook.Application")
              Set myNameSpace = myOlApp.GetNamespace("MAPI")
              Set Sel = Application.ActiveExplorer.Selection
              For I = 1 To Sel.Count
                  If Sel.Item(I).Class = olMeetingRequest Then
                      Set Apointment = Sel.Item(I).GetAssociatedAppointment(True)
                      Apointment.Respond olMeetingAccepted, True, False ' no dialog
                  End If
              Next

      End Sub



Fri, 03 Dec 2004 08:36:42 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Newbie confused: VB6 vs VB.Net vs VBScript vs VBA

2. Newbie confused: VB6 vs VB.Net vs VBscript vs VBA

3. Differences between VB amd VBA and VBA Education

4. Difference between VB and VB in VS

5. Another MaskedEdit Difference VB 4.0 vs VB 5.0

6. -~=###--WHAT IS THE DIFFERENCE BETWEEN HANDLED EVENTS AND UN-HANDLED EVENTS?---#=~-

7. In this case, what's the difference between CSharp and VB.NET Exception Handling

8. VB.Net vs C# - list of major differences

9. VB 4 16 vs 32 bit differences in Execute Method

10. CTRL+BREAK: A difference 'tween VBA 6 and VB 6

11. difference between VBA and VB Script

12. Difference For each VB-VBA

 

 
Powered by phpBB® Forum Software