I want to call a sub on the (first) active item, like this:
[vba] itm = IIf(inspector_window_is_active, _
ActiveInspector.CurrentItem, _
ActiveExplorer.Selection.Item(1))
[/vba]
How to get inspector_window_is_active?
I want to call a sub on the (first) active item, like this:
[vba] itm = IIf(inspector_window_is_active, _
ActiveInspector.CurrentItem, _
ActiveExplorer.Selection.Item(1))
[/vba]
How to get inspector_window_is_active?
I think you mean this:
[vba]Sub Test()
Set itm = GetCurrentItem
End Sub[/vba]
[vba]Function GetCurrentItem() As Object
' returns reference to current item, either the one
' selected (Explorer), or the one currently open (Inspector)
Select Case True
Case IsExplorer(Application.ActiveWindow)
Set GetCurrentItem = ActiveExplorer.Selection.Item(1)
Case IsInspector(Application.ActiveWindow)
Set GetCurrentItem = ActiveInspector.CurrentItem
End Select
End Function
Function IsExplorer(itm As Object) As Boolean
IsExplorer = (TypeName(itm) = "Explorer")
End Function
Function IsInspector(itm As Object) As Boolean
IsInspector = (TypeName(itm) = "Inspector")
End Function[/vba]
Regards,
JP
Read the FAQ
Getting free help on the web
My website
Please use [vba][/vba] tags when posting code
What a great reply! Not only did I get a solution for my problem, but I also learned a cool way to use a Case statement. And, of course, you're right that I would need Set for the assignment of an object.
Thanks a lot for posting this code. It really helped me a lot and I also learned from the Case method you have used.