VB add-in versus VBA

VB add-in versus VBA

Anonymous
Not applicable
241 Views
2 Replies
Message 1 of 3

VB add-in versus VBA

Anonymous
Not applicable
I wrote a VBA Document Project routine to insert drawing borders and title
blocks. It worked fine. I wanted to create drop down menus to access it so I
redid it in VB as an add-in. It compiles fine, but when I try to run it, I
get an error unable to creat Active X component. This is caused by the
following lines:

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Does anyone know what I am missing?
Thanks,
Joe
0 Likes
242 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
VB doesn't know what 'ThisApplication' is so you therefore have to tell it
specifically that your routine is going to be talking to Inventor. You will
need to declare a variable in one of your modules as the Inventor
Application then use this variable in place of 'ThisApplication'.

Public oApp As InventorApplication

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = oApp.ActiveDocument

Hope that helps,

Regards,
Ricky

"Joe Farrell" wrote in message
news:4562961D979C63CB90D8C63B5687CEFF@in.WebX.maYIadrTaRb...
> I wrote a VBA Document Project routine to insert drawing borders and title
> blocks. It worked fine. I wanted to create drop down menus to access it so
I
> redid it in VB as an add-in. It compiles fine, but when I try to run it, I
> get an error unable to creat Active X component. This is caused by the
> following lines:
>
> Dim oDrawDoc As DrawingDocument
> Set oDrawDoc = ThisApplication.ActiveDocument
>
> Does anyone know what I am missing?
> Thanks,
> Joe
>
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks for the help. I had added oApp in the class module, but it wouldn't
work in the form.
I had to use:
Set oApp = GetObject(, "Inventor.Application")


"Ricky Lock" wrote in message
news:41CA44F379324A870ED6287C47A45E98@in.WebX.maYIadrTaRb...
> VB doesn't know what 'ThisApplication' is so you therefore have to tell it
> specifically that your routine is going to be talking to Inventor. You
will
> need to declare a variable in one of your modules as the Inventor
> Application then use this variable in place of 'ThisApplication'.
>
> Public oApp As InventorApplication
>
> Dim oDrawDoc As DrawingDocument
> Set oDrawDoc = oApp.ActiveDocument
>
> Hope that helps,
>
> Regards,
> Ricky
>
> "Joe Farrell" wrote in message
> news:4562961D979C63CB90D8C63B5687CEFF@in.WebX.maYIadrTaRb...
> > I wrote a VBA Document Project routine to insert drawing borders and
title
> > blocks. It worked fine. I wanted to create drop down menus to access it
so
> I
> > redid it in VB as an add-in. It compiles fine, but when I try to run it,
I
> > get an error unable to creat Active X component. This is caused by the
> > following lines:
> >
> > Dim oDrawDoc As DrawingDocument
> > Set oDrawDoc = ThisApplication.ActiveDocument
> >
> > Does anyone know what I am missing?
> > Thanks,
> > Joe
> >
> >
>
>
0 Likes