Additional steps on Excel 2007
In order to make the Nutshell installation work with Visual Basic and Office 2007 (and Vista), you
may have to carry out the steps below, in addition to those in the tutorial in the Help file.
Activate the Developer Bar
- Go to the Office Button (left-upper corner)
- Choose Excel Options at the very bottom
- In the left-hand menu go to Popular (upper menu item)
- On the right, check "Show Developer tab in the Ribbon"
- Press OK
- You should now see the Developer menu in the menu bar
Developer Ribbon
On the left, there is a button with Visual Basic. Clicking it, will bring up the Visual Basic editor
Adding a Nutshell Reference
Make sure Nutshell is installed properly and start it at least once to verify this (you can then close it again). Before you can work comfortably with Nutshell from the Visual Basic Editor, you must add the library to the Tools/References of the Visual Basic Editor.
- In the Tools menu of the Visual Basic Editor, click References
- In the Reference list look for Nutshell and check it
- If it is not in the list but you properly installed Nutshell, add it to the Reference list
- o Press the Browse button on the right
- o Navigate to the c:\Program Files\Nutshell directory (c: may be a different letter on some PCs)
- o Select the file Nutshell.tlb
- o Nutshell now appears in the Reference list and is checked
- o Press OK to close the dialog box
You are now ready to carry out the rest of the Nutshell tutorial, which in the Help file (also accessible from the Start menu) continues as follows:
- 4. Now the Nutshell library is loaded when you start the program you're about to make. All methods and properties of Nutshell can now be accessed from the script. You can also browse through the library by using the object browser. You can find it under the "View" menu.
- Insert a module by selecting "Module" from the "Insert" menu.
A new module is created. It's called Module1 and you can see it under the Modules header in the Project window. You can add an unlimited number of modules to the Project.
Enter the following code:
Sub Create()
' create nutshell application
Set NutApp = CreateObject("Nutshell.Application")
NutApp.Visible = True
End Sub
- Place the text cursor inside the subroutine Create (between Sub Create and End Sub), and then select "Run Sub/User Form" from the "Run" menu.
The sub Create is activated. First it starts Nutshell by the CreateObject method. Then it makes the application visible by setting the Visible item to true.
When everything works out correctly, you'll have Nutshell right in front of you.
Addition on Vista/Excel 2007. It may be that Nutshell is activated but immediately disappears. This is correct behavior because the variable NutApp was created inside a subroutine Create(). When Create ends, it deletes all variables that were created inside it. To remedy this, you must 'declare' the variable outside the subroutine at global scope by using the Dim statement, as follows:
' declare nutshell application
Dim NutApp
Sub Create()
' create nutshell application
Set NutApp = CreateObject("Nutshell.Application")
NutApp.Visible = True
' MsgBox ("Close Nutshell?")
End Sub
|