Message 1 of 4
Struggling with first Add-in - Using Global Variables

Not applicable
08-30-2011
05:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I've been working on converting a VBA macro to an Add-In (my first). I thought all was going well, but I'm struggling to share the InventorApplication object within my add-in...
All the googling I've done suggests the most suitable way is to declare it as a global variable. So I followed the work flow on this page: (http://visualbasic.about.com/od/usevb6/l/blfaq0013a.htm) and created a module to declare my global variables. I've then referenced this module back in the original class, but when I do, I get a message saying "modDeclarations is a type and cannot be used as an expression"... So obviously I'm missing something.
So here's what I've got:
and my modDeclarations looks like this:
If anyone has a good example of using a global variable to access the InventorApplication I'm sure I could figure it out.
Any help would be greatly appreciated. I really can't proceed without solving this one...
I've been working on converting a VBA macro to an Add-In (my first). I thought all was going well, but I'm struggling to share the InventorApplication object within my add-in...
All the googling I've done suggests the most suitable way is to declare it as a global variable. So I followed the work flow on this page: (http://visualbasic.about.com/od/usevb6/l/blfaq0013a.htm) and created a module to declare my global variables. I've then referenced this module back in the original class, but when I do, I get a message saying "modDeclarations is a type and cannot be used as an expression"... So obviously I'm missing something.
So here's what I've got:
Code:
Imports Inventor Imports System.Runtime.InteropServices Imports Microsoft.Win32 Imports System.Windows.Forms Namespace HDALLabelMaker <ProgIdAttribute("HDAL Label Maker.StandardAddInServer"), _ GuidAttribute("57440e51-bcc8-4abb-a1f0-09493c3981de")> _ Public Class StandardAddInServer Implements Inventor.ApplicationAddInServer ' Inventor application object. 'Public m_inventorApplication As Inventor.Application Private m_ClientID As String Private WithEvents oButtonActivate As Inventor.ButtonDefinition #Region "ApplicationAddInServer Members" Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate ' This method is called by Inventor when it loads the AddIn. ' The AddInSiteObject provides access to the Inventor Application object. ' The FirstTime flag indicates if the AddIn is loaded for the first time. ' Initialize AddIn members. modDeclarations() m_inventorApplication = addInSiteObject.Application
and my modDeclarations looks like this:
Code:
Public Module modDeclarations Public m_inventorApplication As Inventor.Application End Module
I've also attached my full project if anyone is interested.
If anyone has a good example of using a global variable to access the InventorApplication I'm sure I could figure it out.
Any help would be greatly appreciated. I really can't proceed without solving this one...