I'm working in C#.net and basically I want my plug-in to be able to tell if when the user saves, the save is coming from Excel itself or if the save is coming from the "Visual Basic for Application" window.
Is there a way to tell if the user is currently in the "Microsoft Visual Basic for Application" or not?
Edit: I don't know if this is a full prof solution but I've found that .Application.ActiveWindow.ActiveSheet == null seems to be working.
on error resume next set wbk = workbooks("MyBook.xls") on error goto 0 is wbk is nothing then _ set wbk = workbooks.open("Mybook.xls")
You could do something like this to return a boolean True/False
if the project's VBE window is open. I'm not sure what the C# equivalent would be, but you may be able to simply check whether the Workbook's VBProject VB Editor is active:
Function IsVBEActive(wb as Workbook) As Boolean
Dim vbProj
Set vbProj = wb.vbProject
IsVBEActive <> vbProj.VBE.ActiveWindow Is Nothing
End Sub
NOTE This requires enabling trusted access to the VB Project Object Model:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With