Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub PreviousSheet()
- On Error Resume Next
- ActiveSheet.Previous.Select
- End Sub
- Sub NextSheet()
- On Error Resume Next
- ActiveSheet.Next.Select
- End Sub
- Sub test()
- Dim olApp As Outlook.Application
- Set olApp = GetOutlookApp()
- 'I think this is how to loop through the open items?
- For i = olApp.Inspectors.Count To 1 Step -1
- Set olItem = olApp.Inspectors.Item(i).CurrentItem
- olItem.Select 'How do I set focus?
- Next i
- End Sub
- Function GetOutlookApp() As Outlook.Application
- ' returns reference to native Application object
- Set GetOutlookApp = Outlook.Application
- End Function
- Sub GetPreviousOpenItem()
- Set MainWindow = Application.ActiveExplorer
- Dim olApp As Outlook.Application
- Set olApp = GetOutlookApp()
- If olApp.ActiveInspector Is Nothing Then
- Exit Sub
- End If
- ActiveInspectorIndex = GetIndexOfActiveInspector(olApp, olApp.ActiveInspector)
- If ActiveInspectorIndex - 1 > 0 Then
- Dim PreviousInspector As Inspector
- Set PreviousInspector = olApp.Inspectors(ActiveInspectorIndex - 1)
- olApp.Inspectors(ActiveInspectorIndex - 1).Display
- Else
- olApp.Inspectors(olApp.Inspectors.Count).Display
- End If
- MainWindow.Activate
- End Sub
- Sub GetNextOpenItem()
- Set MainWindow = Application.ActiveExplorer
- Dim olApp As Outlook.Application
- Set olApp = GetOutlookApp()
- If olApp.ActiveInspector Is Nothing Then
- Exit Sub
- End If
- ActiveInspectorIndex = GetIndexOfActiveInspector(olApp, olApp.ActiveInspector)
- If ActiveInspectorIndex + 1 <= olApp.Inspectors.Count Then
- Dim NextInspector As Inspector
- Set NextInspector = olApp.Inspectors(ActiveInspectorIndex + 1)
- NextInspector.Display
- Else
- olApp.Inspectors(1).Display
- End If
- MainWindow.Activate
- End Sub
- Function GetIndexOfActiveInspector(olApp, CurrentItem) As Integer
- CurrentItem = olApp.ActiveInspector
- For i = 1 To olApp.Inspectors.Count
- Dim Inspector
- Set Inspector = olApp.Inspectors.Item(i)
- Set olItem = Inspector.CurrentItem
- If olItem Is CurrentItem Then
- GetIndexOfActiveInspector = i
- Exit Function
- End If
- Next i
- MainWindow.Activate
- End Function
- Function GetOutlookApp() As Outlook.Application
- ' returns reference to native Application object
- Set GetOutlookApp = Outlook.Application
- End Function
Add Comment
Please, Sign In to add comment