Advertisement
burssen

Get selected item from Outlook and run scripts on it

Feb 4th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function GetCurrentItem() As Object
  2. '******
  3. 'this function gets the selected item into an object. The item can be selected from an Explorer (folder View) or an Inspector (item View)
  4. '******
  5.  
  6.     Dim objOL As Outlook.Application
  7.     Dim strWindowType As String
  8.     On Error Resume Next
  9.    
  10.     Set objOL = Outlook.Application
  11.     strWindowType = TypeName(objOL.ActiveWindow)
  12.    
  13.     Select Case strWindowType
  14.         Case "Explorer"
  15.             'MsgBox "You selected a folder"
  16.            Set GetCurrentItem = objOL.ActiveExplorer.Selection(1)
  17.         Case "Inspector"
  18.             'MsgBox "You have opened an item"
  19.            Set GetCurrentItem = objOL.ActiveInspector.CurrentItem
  20.     End Select
  21.    
  22.     Set objOL = Nothing
  23.  
  24. End Function
  25.  
  26.  
  27. Sub PrintDaten()
  28.     Dim objItem As Object
  29.    
  30.     Set objItem = GetCurrentItem()
  31.     Call Printare
  32.    
  33.  
  34. End Sub
  35.  
  36.  
  37. Sub Printare()
  38.     MsgBox "Acum printez Daten"
  39.  
  40.  
  41. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement