Guest User

Untitled

a guest
Mar 23rd, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. Sub PreviousSheet()
  2. On Error Resume Next
  3. ActiveSheet.Previous.Select
  4. End Sub
  5.  
  6. Sub NextSheet()
  7. On Error Resume Next
  8. ActiveSheet.Next.Select
  9. End Sub
  10.  
  11. Sub test()
  12.  
  13. Dim olApp As Outlook.Application
  14. Set olApp = GetOutlookApp()
  15.  
  16. 'I think this is how to loop through the open items?
  17. For i = olApp.Inspectors.Count To 1 Step -1
  18. Set olItem = olApp.Inspectors.Item(i).CurrentItem
  19. olItem.Select 'How do I set focus?
  20. Next i
  21.  
  22. End Sub
  23.  
  24. Function GetOutlookApp() As Outlook.Application
  25. ' returns reference to native Application object
  26. Set GetOutlookApp = Outlook.Application
  27. End Function
  28.  
  29. Sub GetPreviousOpenItem()
  30.  
  31. Set MainWindow = Application.ActiveExplorer
  32.  
  33. Dim olApp As Outlook.Application
  34. Set olApp = GetOutlookApp()
  35.  
  36. If olApp.ActiveInspector Is Nothing Then
  37. Exit Sub
  38. End If
  39.  
  40. ActiveInspectorIndex = GetIndexOfActiveInspector(olApp, olApp.ActiveInspector)
  41.  
  42. If ActiveInspectorIndex - 1 > 0 Then
  43. Dim PreviousInspector As Inspector
  44. Set PreviousInspector = olApp.Inspectors(ActiveInspectorIndex - 1)
  45. olApp.Inspectors(ActiveInspectorIndex - 1).Display
  46. Else
  47. olApp.Inspectors(olApp.Inspectors.Count).Display
  48. End If
  49.  
  50. MainWindow.Activate
  51.  
  52. End Sub
  53.  
  54. Sub GetNextOpenItem()
  55.  
  56. Set MainWindow = Application.ActiveExplorer
  57.  
  58. Dim olApp As Outlook.Application
  59. Set olApp = GetOutlookApp()
  60.  
  61. If olApp.ActiveInspector Is Nothing Then
  62. Exit Sub
  63. End If
  64.  
  65. ActiveInspectorIndex = GetIndexOfActiveInspector(olApp, olApp.ActiveInspector)
  66.  
  67. If ActiveInspectorIndex + 1 <= olApp.Inspectors.Count Then
  68. Dim NextInspector As Inspector
  69. Set NextInspector = olApp.Inspectors(ActiveInspectorIndex + 1)
  70. NextInspector.Display
  71. Else
  72. olApp.Inspectors(1).Display
  73. End If
  74.  
  75. MainWindow.Activate
  76.  
  77. End Sub
  78.  
  79. Function GetIndexOfActiveInspector(olApp, CurrentItem) As Integer
  80.  
  81. CurrentItem = olApp.ActiveInspector
  82.  
  83. For i = 1 To olApp.Inspectors.Count
  84.  
  85. Dim Inspector
  86. Set Inspector = olApp.Inspectors.Item(i)
  87. Set olItem = Inspector.CurrentItem
  88.  
  89. If olItem Is CurrentItem Then
  90. GetIndexOfActiveInspector = i
  91. Exit Function
  92. End If
  93.  
  94. Next i
  95.  
  96. MainWindow.Activate
  97.  
  98. End Function
  99. Function GetOutlookApp() As Outlook.Application
  100. ' returns reference to native Application object
  101. Set GetOutlookApp = Outlook.Application
  102. End Function
Add Comment
Please, Sign In to add comment