I'm trying to Close the OneNote Application from VBA excel with this piece of code:
Sub closeOneNote()
Dim oneNoteApp As Object
On Error Resume Next
Set oneNoteApp = GetObject(, "OneNote.Application")
If Err.Number = 0 Then
oneNoteApp.Quit
Else
Err.Clear
End If
End Sub
When I try with Outlook instead of OneNote, it works fine and Outlook closes. I was wondering if it was because OneNote is not an application that supports automation through VBA. As shown in the below link, the table at the bottom of the page lists all the top-level Office objects Ican reference and their class names and OneNote is not among them:
Creation of Object Variables to Automate Another Office Application
Any ideas, suggestions on how to close the application (not the notebooks themselves, only the application running.. )
Thanks
On Error Resume Next
you might be able to debug this... – David ZemensGetObject
or.Quit
? – David ZemensCreateObject
to get OneNote application, or dimension it as an object variable and use theCreateObject
or Dim as New` methods.Quit
will still fail. It is simply not supported. – David Zemens