Visual Basic Customization

Reply
*Elmore, Andrew
Message 1 of 6 (54 Views)

programs to work with 04 & 03

54 Views, 5 Replies
07-29-2003 10:14 AM
How can I add references in my projects to work with ADT 3.3 and 04. I use
04 but some people are still useing 3.3 so I need both refs.

Thanks,
Andy
*P., Danny
Message 2 of 6 (54 Views)

Re: programs to work with 04 & 03

07-30-2003 05:09 AM in reply to: *Elmore, Andrew
Andrew,

I would venture a guess that you can't do this. This was an issue with 3.0
& 3.3, and it required us to maintain 2 versions, one for 3.0 and one for
3.3. Although I haven't tested it, I would say that this is still true.

You might also try posting this in the
autodesk.aec.arch-desktop.customization newsgroup. Some of the ADT API
developers lurk there and will probably post back.

Hope that helps,
-Danny Polkinhorn
Perkins & Will
Atlanta

"Andrew Elmore" wrote in message
news:997ECFDE9CB228122E33A8F6A95A7AB5@in.WebX.maYIadrTaRb...
> How can I add references in my projects to work with ADT 3.3 and 04. I use
> 04 but some people are still useing 3.3 so I need both refs.
>
> Thanks,
> Andy
>
>
*Elmore, Andrew
Message 3 of 6 (54 Views)

Re:

07-30-2003 06:22 AM in reply to: *Elmore, Andrew
Thanks I'll give it a try.
Andy

"Danny P." wrote in message
news:6DAE2A3302775580E6BA66645FE511D3@in.WebX.maYIadrTaRb...
> Andrew,
>
> I would venture a guess that you can't do this. This was an issue with
3.0
> & 3.3, and it required us to maintain 2 versions, one for 3.0 and one for
> 3.3. Although I haven't tested it, I would say that this is still true.
>
> You might also try posting this in the
> autodesk.aec.arch-desktop.customization newsgroup. Some of the ADT API
> developers lurk there and will probably post back.
>
> Hope that helps,
> -Danny Polkinhorn
> Perkins & Will
> Atlanta
>
> "Andrew Elmore" wrote in message
> news:997ECFDE9CB228122E33A8F6A95A7AB5@in.WebX.maYIadrTaRb...
> > How can I add references in my projects to work with ADT 3.3 and 04. I
use
> > 04 but some people are still useing 3.3 so I need both refs.
> >
> > Thanks,
> > Andy
> >
> >
>
>
*Comerford, Laurie
Message 4 of 6 (54 Views)

Re: programs to work with 04 & 03

07-30-2003 11:14 AM in reply to: *Elmore, Andrew
Hi Andrew,

I have been trying to resolve this issue in a desultary fashion for some
time.

The information below comes from the AUGI VBA Guild. It start with Richard
Binning providing information which I tried and I succeeded in loading the
ALD libraries based on Richard's suggestions.

However, I could not get my code to recognise that the libraries were
loaded.

The top message posted today by Ed Jobe in the AUGI VBA guild is my next
port of call.

I haven't had time to try Ed's suggestions yet, but the more of us that try,
the more likely we will be to get a working answer.

Lastly, I have some information from Autodesk, that the process may be
affected by a bug in the AutoCAD API's and for the moment it may not work
anyhow with R2004.
--


Laurie Comerford
CADApps
www.cadapps.com.au


----- Original Message -----
From: Ed Jobe
To: guild-vba@augi.com
Sent: Thursday, July 31, 2003 4:03 AM
Subject: [VBA] Setting references programmatically


A while back, someone asked how to set references programmatically, as
in when you have different versions of a program you need to reference.
The requestor was having trouble with the vbaide prompting to save the
project after the reference was set. I just now had time to check into
it. If you clean up after yourself, deleting the reference, you won't
have this problem. I modified my functions to allow for this. I also
added one to set the ref by GUID. That way you don't have to worry about
checking for a valid file path. You can get the necessary GUID info
using the sample sub below.


Sub testref1()
'Sample to demonstrate working with references
'Set reference for ADO.
'"Microsoft AcitveX Data Objects library 2.7"
Dim objRef As vbide.Reference
Set objRef = SetReferenceByFile("C:\Program Files\Common
Files\system\ado\msado15.dll")
' Set objRef =
SetReferenceByGUID("{EF53050B-882E-4776-B643-EDA472E8E3F2}", 2, 7)
If objRef Is Nothing Then
MsgBox Err.Number & ", " & Err.Description, vbExclamation,
"Error setting reference."
Else
Debug.Print objRef.Guid & ", " & objRef.Major & ", " &
objRef.Minor
End If
DeleteReference objRef

End Sub


Public Function DeleteReference(ref As vbide.Reference)
On Error GoTo ErrorHandler
Dim objVB As VBE
Dim objRef As Reference

Set objVB = Application.VBE
objVB.ActiveVBProject.References.Remove ref
GoTo Finish:
ErrorHandler:
MsgBox Err.Number & ", " & Err.Description, vbExclamation,
"Error deleting reference."
Finish:
Set objVB = Nothing
End Function

Public Function SetReferenceByFile(filepath As String, Optional
DisplayErrors As Boolean) As vbide.Reference
'Returns a Reference object if successful in setting a reference in
the current dvb,
'given the FilePath of a tlb, olb, dll. The DisplayErrors option
determines
'whether or not an error message will be displayed upon erroring.
On Error GoTo ErrorHandler
Dim objVB As VBE
Dim objRef As vbide.Reference
Dim objRefs As vbide.References
Dim strPath As String

Set objVB = Application.VBE
Set objRef =
objVB.ActiveVBProject.References.AddFromFile(filepath)
Set SetReferenceByFile = objRef
GoTo Finish:
ErrorHandler:
If Err.Number = 32813 Then
'reference was already set, just return True
Set objRefs = objVB.ActiveVBProject.References
For Each objRef In objRefs
If objRef.FullPath = filepath Then
Set SetReferenceByFile = objRef
End If
Next objRef
Else
If DisplayErrors = True Then
MsgBox Err.Number & ", " & Err.Description, vbExclamation,
"Error setting reference."
Else

End If
Set SetReferenceByFile = Nothing
End If
Finish:
Set objVB = Nothing
Set objRef = Nothing
End Function

Public Function SetReferenceByGUID(strGUID As String, maj As Long, min
As Long) As vbide.Reference
'Returns a Reference object if successful in setting a reference in
the current dvb,
'given the GUID of a tlb, olb, dll. Using a GUID avoids having to
test
'for a valid filepath.
On Error GoTo ErrorHandler
Dim objVB As VBE
Dim objRef As vbide.Reference
Dim strPath As String

Set objVB = Application.VBE
Set objRef = objVB.ActiveVBProject.References.AddFromGuid(strGUID,
1, 1)
Set SetReferenceByGUID = objRef
GoTo Finish:
ErrorHandler:
If Err.Number = 32813 Then
'reference was already set, just return True
Set SetReferenceByGUID = objRef
Else
Set SetReferenceByGUID = Nothing
End If
Finish:
Set objVB = Nothing
Set objRef = Nothing
End Function

Ed Jobe
guild-lisp-moderator@augi.com
guild-mdt-moderator@augi.com

---footer---
You are receiving this message because you are subscribed to
guild-vba@augi.com. If you wish to unsubscribe from this list, please send
an email to mailto:guild-vba-request@augi.com?Subject=unsubscribe with the
word "unsubscribe" (without the quotes) in the subject of the email and
follow any instructions that follow. If you require any help with
subscription matters or general Guild information then please send an email
to mailto:guild-list-moderators@augi.com.

------------------------------------

----- Original Message -----
From: Binning, Richard L.
To: 'kdayman@UMAGroup.com' ; VBA Guild (guild-vba@augi.com)
Sent: Wednesday, July 23, 2003 10:44 PM
Subject: Re: [VBA] FW: Loading References when ALD but not Vanilla ACAD


You can check the registry for the application that is running the macro.
Check the "default" value of this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\acad.exe

From the path to the executable, you should be able to detect what flavor
the application
is.

You could also check the current profile with a function like that shown
below:

Function Get_ActiveProfile() As String
' This function returns the current setting of
' ActiveProfile.
On Error Goto Err_Relief
Dim preferences As AcadPreferences
Dim currActiveProfile As String
Set preferences = ThisDrawing.Application.preferences
' Retrieve the current ActiveProfile value
currActiveProfile = preferences.Profiles.ActiveProfile
Err_Relief:
If Len(currActiveProfile) < 1 then
msgbox "Error detected, profile unknown!"
Else
Get_ActiveProfile = currActiveProfile
End if
Set preferences = Nothing
End Function

To set a reference to a particular library, you will have to add a reference
to the microsoft vba extensibility 5.3 library.
You can then declare some objects to hold the reference values such as:

Dim oVBE As VBIDE.VBE
Dim oVBP As VBIDE.VBProject
Dim oVBPs as VBIDE.VBProjects
Dim oVBR As VBIDE.Reference
Dim oVBRs As VBIDE.References

Now populate your objects...

Set oVBE = Application.VBE
Set oVBPs = oVBE.VBProjects
Set oVBP = oVBPs("Your project title")
Set oVBRs = oVBP.References

You should be able to try attaching your desired ref here and do some
trapping.

On Error Resume Next
Set oVBR = oVBRs("Your Type Library")
If Err then
'clean it up
else
'restore proper error handling here
endif


Does that give you enough to get started?

P.S. I wrote that on the fly not in the VBA editor so I might have some
error of exclusion or spelling.




Richard Binning

AUGI Guild Moderator

AUGI Exchange Approvals Manager

Member # 15067

Win2k SP2

Acad 2002

Architectural Desktop 3.3 SP2

Land Development Desktop 3.0

Building Systems 3.0

PIV 1.3 GHZ

512 RAM

OXYGEN GVX1 32mb AGP

Mailto: guild-cadmgr-moderator@augi.com







> -----Original Message-----
> From: Kelly Dayman (Bur) [mailto:kdayman@UMAGroup.com]
> Sent: Tuesday, July 22, 2003 7:39 PM
> To: VBA Guild (guild-vba@augi.com)
> Subject: [VBA] FW: Loading References when ALD but not Vanilla ACAD
>
>
>
>
> -----Original Message-----
> From: Kelly Dayman (Bur)
> Sent: Tuesday, July 22, 2003 4:28 PM
> To: 'Wes Stueve'; Kelly Dayman (Bur)
> Subject: RE: [VBA] Loading References when ALD but not Vanilla ACAD
>
> Thanks Wes, triggered some ideas but no result (stupid brain).
> By big problem is how to load a reference at run time?
>
> Thanks,
> Kelly
>
> -----Original Message-----
> From: Wes Stueve [mailto:Wes.Stueve@hendersonengineers.com]
> Sent: Tuesday, July 22, 2003 3:23 PM
> To: kdayman@UMAGroup.com
> Subject: RE: [VBA] Loading References when ALD but not Vanilla ACAD
>
> Which part fails? Does the AeccApplication application
> object exist on
> machines without ALD? If that is the case, you can say
> (after removing the
> reference):
>
> Dim obj
>
> On Error Resume Next
>
> Set obj = GetObject(,"[REFERENCELIB].AeccApplication")
> If Err.Number <> 0 Then
> 'it is not on this machine
> End if
>
> The reference library should be able to be found in the
> registry. Just do a
> search for AeccApplication until you find something that
> looks right. Look
> at the GetObject and CreateObject functinons for help on
> locating this.
>
> Don't know if this helps you or not, but good luck!
>
> Wes
>
> -----Original Message-----
> From: Kelly Dayman (Bur) [mailto:kdayman@UMAGroup.com]
> Sent: Tuesday, July 22, 2003 5:12 PM
> To: 'Laurie Comerford'; Kelly Dayman (Bur); guild-vba@augi.com
> Subject: Re: [VBA] Loading References when ALD but not Vanilla ACAD
>
>
> I want to only load the ALD Library if ALD is the application that is
> running the VBA. However if I reference the library then try
> to run on a
> station that does not have ALD the VBA application gets very upset.
>
> I know this is possible I was involved in a thread that
> discussed it about 4
> months ago, however I have changed computers since then and I did not
> transfer the info over. As soon as you get rid of something
> you need it!!
>
> Kelly
>
> -----Original Message-----
> From: Laurie Comerford [mailto:laurie@cadapps.com.au]
> Sent: Tuesday, July 22, 2003 3:12 PM
> To: kdayman@UMAGroup.com; guild-vba@augi.com
> Subject: Re: [VBA] Loading References when ALD but not Vanilla ACAD
>
> Hi Kelly,
>
> I doubt that it would be legal for you to use ALD library
> files on non-ALD AutoCADs.
>
> One way of dealing with the issue is to include the library
> as a reference
> in your program and then call the program with a lisp
> function which checks
> the AutoCAD version which is running and returns an error
> message if it's
> not ALD.
>
>
> Laurie Comerford
> CADApps
> www.cadapps.com.au <>
> ----- Original Message -----
> From: Kelly Dayman (Bur)
> To: VBA Guild (guild-vba@augi.com)
> Sent: Wednesday, July 23, 2003 3:48 AM
> Subject: [VBA] Loading References when ALD but not Vanilla ACAD
>
> I am working on a routine that will run on many different
> platform ALD, ACAD
> etc. When ALD is the current app I need to run the following
> statement:
>
> AeccApplication.ActiveDocument.Preferences.databasescale = dblScale
>
> However I must load the associated Reference when in ALD in
> order for this
> to work, machines without ALD will not have this reference available.
>
> Reference Lib AUTODESK LAND 1.2 TYPR LIBRARY
>
> What is the best method to check if the app is ALD and load
> the library in
> the code?
>
> Kelly Dayman
> UMA Group Ltd.
>
>
---footer---
You are receiving this message because you are subscribed to
guild-vba@augi.com. If you wish to unsubscribe from this list, please send
an email to mailto:guild-vba-request@augi.com?Subject=unsubscribe with the
word "unsubscribe" (without the quotes) in the subject of the email and
follow any instructions that follow. If you require any help with
subscription matters or general Guild information then please send an email
to mailto:guild-list-moderators@augi.com.

-------------------------------------

"Andrew Elmore" wrote in message
news:997ECFDE9CB228122E33A8F6A95A7AB5@in.WebX.maYIadrTaRb...
> How can I add references in my projects to work with ADT 3.3 and 04. I use
> 04 but some people are still useing 3.3 so I need both refs.
>
> Thanks,
> Andy
>
>
*Elmore, Andy
Message 5 of 6 (54 Views)

Re:

08-04-2003 02:21 PM in reply to: *Elmore, Andrew
test

"Laurie Comerford" wrote in message
news:914024A6EE61D23528FAE9C425655CC9@in.WebX.maYIadrTaRb...
> Hi Andrew,
>
> I have been trying to resolve this issue in a desultary fashion for some
> time.
>
> The information below comes from the AUGI VBA Guild. It start with
Richard
> Binning providing information which I tried and I succeeded in loading the
> ALD libraries based on Richard's suggestions.
>
> However, I could not get my code to recognise that the libraries were
> loaded.
>
> The top message posted today by Ed Jobe in the AUGI VBA guild is my next
> port of call.
>
> I haven't had time to try Ed's suggestions yet, but the more of us that
try,
> the more likely we will be to get a working answer.
>
> Lastly, I have some information from Autodesk, that the process may be
> affected by a bug in the AutoCAD API's and for the moment it may not work
> anyhow with R2004.
> --
>
>
> Laurie Comerford
> CADApps
> www.cadapps.com.au
>
>
> ----- Original Message -----
> From: Ed Jobe
> To: guild-vba@augi.com
> Sent: Thursday, July 31, 2003 4:03 AM
> Subject: [VBA] Setting references programmatically
>
>
> A while back, someone asked how to set references programmatically, as
> in when you have different versions of a program you need to reference.
> The requestor was having trouble with the vbaide prompting to save the
> project after the reference was set. I just now had time to check into
> it. If you clean up after yourself, deleting the reference, you won't
> have this problem. I modified my functions to allow for this. I also
> added one to set the ref by GUID. That way you don't have to worry about
> checking for a valid file path. You can get the necessary GUID info
> using the sample sub below.
>
>
> Sub testref1()
> 'Sample to demonstrate working with references
> 'Set reference for ADO.
> '"Microsoft AcitveX Data Objects library 2.7"
> Dim objRef As vbide.Reference
> Set objRef = SetReferenceByFile("C:\Program Files\Common
> Files\system\ado\msado15.dll")
> ' Set objRef =
> SetReferenceByGUID("{EF53050B-882E-4776-B643-EDA472E8E3F2}", 2, 7)
> If objRef Is Nothing Then
> MsgBox Err.Number & ", " & Err.Description, vbExclamation,
> "Error setting reference."
> Else
> Debug.Print objRef.Guid & ", " & objRef.Major & ", " &
> objRef.Minor
> End If
> DeleteReference objRef
>
> End Sub
>
>
> Public Function DeleteReference(ref As vbide.Reference)
> On Error GoTo ErrorHandler
> Dim objVB As VBE
> Dim objRef As Reference
>
> Set objVB = Application.VBE
> objVB.ActiveVBProject.References.Remove ref
> GoTo Finish:
> ErrorHandler:
> MsgBox Err.Number & ", " & Err.Description, vbExclamation,
> "Error deleting reference."
> Finish:
> Set objVB = Nothing
> End Function
>
> Public Function SetReferenceByFile(filepath As String, Optional
> DisplayErrors As Boolean) As vbide.Reference
> 'Returns a Reference object if successful in setting a reference in
> the current dvb,
> 'given the FilePath of a tlb, olb, dll. The DisplayErrors option
> determines
> 'whether or not an error message will be displayed upon erroring.
> On Error GoTo ErrorHandler
> Dim objVB As VBE
> Dim objRef As vbide.Reference
> Dim objRefs As vbide.References
> Dim strPath As String
>
> Set objVB = Application.VBE
> Set objRef =
> objVB.ActiveVBProject.References.AddFromFile(filepath)
> Set SetReferenceByFile = objRef
> GoTo Finish:
> ErrorHandler:
> If Err.Number = 32813 Then
> 'reference was already set, just return True
> Set objRefs = objVB.ActiveVBProject.References
> For Each objRef In objRefs
> If objRef.FullPath = filepath Then
> Set SetReferenceByFile = objRef
> End If
> Next objRef
> Else
> If DisplayErrors = True Then
> MsgBox Err.Number & ", " & Err.Description, vbExclamation,
> "Error setting reference."
> Else
>
> End If
> Set SetReferenceByFile = Nothing
> End If
> Finish:
> Set objVB = Nothing
> Set objRef = Nothing
> End Function
>
> Public Function SetReferenceByGUID(strGUID As String, maj As Long, min
> As Long) As vbide.Reference
> 'Returns a Reference object if successful in setting a reference in
> the current dvb,
> 'given the GUID of a tlb, olb, dll. Using a GUID avoids having to
> test
> 'for a valid filepath.
> On Error GoTo ErrorHandler
> Dim objVB As VBE
> Dim objRef As vbide.Reference
> Dim strPath As String
>
> Set objVB = Application.VBE
> Set objRef = objVB.ActiveVBProject.References.AddFromGuid(strGUID,
> 1, 1)
> Set SetReferenceByGUID = objRef
> GoTo Finish:
> ErrorHandler:
> If Err.Number = 32813 Then
> 'reference was already set, just return True
> Set SetReferenceByGUID = objRef
> Else
> Set SetReferenceByGUID = Nothing
> End If
> Finish:
> Set objVB = Nothing
> Set objRef = Nothing
> End Function
>
> Ed Jobe
> guild-lisp-moderator@augi.com
> guild-mdt-moderator@augi.com
>
> ---footer---
> You are receiving this message because you are subscribed to
> guild-vba@augi.com. If you wish to unsubscribe from this list, please send
> an email to mailto:guild-vba-request@augi.com?Subject=unsubscribe with the
> word "unsubscribe" (without the quotes) in the subject of the email and
> follow any instructions that follow. If you require any help with
> subscription matters or general Guild information then please send an
email
> to mailto:guild-list-moderators@augi.com.
>
> ------------------------------------
>
> ----- Original Message -----
> From: Binning, Richard L.
> To: 'kdayman@UMAGroup.com' ; VBA Guild (guild-vba@augi.com)
> Sent: Wednesday, July 23, 2003 10:44 PM
> Subject: Re: [VBA] FW: Loading References when ALD but not Vanilla ACAD
>
>
> You can check the registry for the application that is running the macro.
> Check the "default" value of this key:
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
> Paths\acad.exe
>
> From the path to the executable, you should be able to detect what flavor
> the application
> is.
>
> You could also check the current profile with a function like that shown
> below:
>
> Function Get_ActiveProfile() As String
> ' This function returns the current setting of
> ' ActiveProfile.
> On Error Goto Err_Relief
> Dim preferences As AcadPreferences
> Dim currActiveProfile As String
> Set preferences = ThisDrawing.Application.preferences
> ' Retrieve the current ActiveProfile value
> currActiveProfile = preferences.Profiles.ActiveProfile
> Err_Relief:
> If Len(currActiveProfile) < 1 then
> msgbox "Error detected, profile unknown!"
> Else
> Get_ActiveProfile = currActiveProfile
> End if
> Set preferences = Nothing
> End Function
>
> To set a reference to a particular library, you will have to add a
reference
> to the microsoft vba extensibility 5.3 library.
> You can then declare some objects to hold the reference values such as:
>
> Dim oVBE As VBIDE.VBE
> Dim oVBP As VBIDE.VBProject
> Dim oVBPs as VBIDE.VBProjects
> Dim oVBR As VBIDE.Reference
> Dim oVBRs As VBIDE.References
>
> Now populate your objects...
>
> Set oVBE = Application.VBE
> Set oVBPs = oVBE.VBProjects
> Set oVBP = oVBPs("Your project title")
> Set oVBRs = oVBP.References
>
> You should be able to try attaching your desired ref here and do some
> trapping.
>
> On Error Resume Next
> Set oVBR = oVBRs("Your Type Library")
> If Err then
> 'clean it up
> else
> 'restore proper error handling here
> endif
>
>
> Does that give you enough to get started?
>
> P.S. I wrote that on the fly not in the VBA editor so I might have some
> error of exclusion or spelling.
>
>
>
>
> Richard Binning
>
> AUGI Guild Moderator
>
> AUGI Exchange Approvals Manager
>
> Member # 15067
>
> Win2k SP2
>
> Acad 2002
>
> Architectural Desktop 3.3 SP2
>
> Land Development Desktop 3.0
>
> Building Systems 3.0
>
> PIV 1.3 GHZ
>
> 512 RAM
>
> OXYGEN GVX1 32mb AGP
>
> Mailto: guild-cadmgr-moderator@augi.com
>
>
>
>
>
>
>
> > -----Original Message-----
> > From: Kelly Dayman (Bur) [mailto:kdayman@UMAGroup.com]
> > Sent: Tuesday, July 22, 2003 7:39 PM
> > To: VBA Guild (guild-vba@augi.com)
> > Subject: [VBA] FW: Loading References when ALD but not Vanilla ACAD
> >
> >
> >
> >
> > -----Original Message-----
> > From: Kelly Dayman (Bur)
> > Sent: Tuesday, July 22, 2003 4:28 PM
> > To: 'Wes Stueve'; Kelly Dayman (Bur)
> > Subject: RE: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > Thanks Wes, triggered some ideas but no result (stupid brain).
> > By big problem is how to load a reference at run time?
> >
> > Thanks,
> > Kelly
> >
> > -----Original Message-----
> > From: Wes Stueve [mailto:Wes.Stueve@hendersonengineers.com]
> > Sent: Tuesday, July 22, 2003 3:23 PM
> > To: kdayman@UMAGroup.com
> > Subject: RE: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > Which part fails? Does the AeccApplication application
> > object exist on
> > machines without ALD? If that is the case, you can say
> > (after removing the
> > reference):
> >
> > Dim obj
> >
> > On Error Resume Next
> >
> > Set obj = GetObject(,"[REFERENCELIB].AeccApplication")
> > If Err.Number <> 0 Then
> > 'it is not on this machine
> > End if
> >
> > The reference library should be able to be found in the
> > registry. Just do a
> > search for AeccApplication until you find something that
> > looks right. Look
> > at the GetObject and CreateObject functinons for help on
> > locating this.
> >
> > Don't know if this helps you or not, but good luck!
> >
> > Wes
> >
> > -----Original Message-----
> > From: Kelly Dayman (Bur) [mailto:kdayman@UMAGroup.com]
> > Sent: Tuesday, July 22, 2003 5:12 PM
> > To: 'Laurie Comerford'; Kelly Dayman (Bur); guild-vba@augi.com
> > Subject: Re: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> >
> > I want to only load the ALD Library if ALD is the application that is
> > running the VBA. However if I reference the library then try
> > to run on a
> > station that does not have ALD the VBA application gets very upset.
> >
> > I know this is possible I was involved in a thread that
> > discussed it about 4
> > months ago, however I have changed computers since then and I did not
> > transfer the info over. As soon as you get rid of something
> > you need it!!
> >
> > Kelly
> >
> > -----Original Message-----
> > From: Laurie Comerford [mailto:laurie@cadapps.com.au]
> > Sent: Tuesday, July 22, 2003 3:12 PM
> > To: kdayman@UMAGroup.com; guild-vba@augi.com
> > Subject: Re: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > Hi Kelly,
> >
> > I doubt that it would be legal for you to use ALD library
> > files on non-ALD AutoCADs.
> >
> > One way of dealing with the issue is to include the library
> > as a reference
> > in your program and then call the program with a lisp
> > function which checks
> > the AutoCAD version which is running and returns an error
> > message if it's
> > not ALD.
> >
> >
> > Laurie Comerford
> > CADApps
> > www.cadapps.com.au <>
> > ----- Original Message -----
> > From: Kelly Dayman (Bur)
> > To: VBA Guild (guild-vba@augi.com)
> > Sent: Wednesday, July 23, 2003 3:48 AM
> > Subject: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > I am working on a routine that will run on many different
> > platform ALD, ACAD
> > etc. When ALD is the current app I need to run the following
> > statement:
> >
> > AeccApplication.ActiveDocument.Preferences.databasescale = dblScale
> >
> > However I must load the associated Reference when in ALD in
> > order for this
> > to work, machines without ALD will not have this reference available.
> >
> > Reference Lib AUTODESK LAND 1.2 TYPR LIBRARY
> >
> > What is the best method to check if the app is ALD and load
> > the library in
> > the code?
> >
> > Kelly Dayman
> > UMA Group Ltd.
> >
> >
> ---footer---
> You are receiving this message because you are subscribed to
> guild-vba@augi.com. If you wish to unsubscribe from this list, please send
> an email to mailto:guild-vba-request@augi.com?Subject=unsubscribe with the
> word "unsubscribe" (without the quotes) in the subject of the email and
> follow any instructions that follow. If you require any help with
> subscription matters or general Guild information then please send an
email
> to mailto:guild-list-moderators@augi.com.
>
> -------------------------------------
>
> "Andrew Elmore" wrote in message
> news:997ECFDE9CB228122E33A8F6A95A7AB5@in.WebX.maYIadrTaRb...
> > How can I add references in my projects to work with ADT 3.3 and 04. I
use
> > 04 but some people are still useing 3.3 so I need both refs.
> >
> > Thanks,
> > Andy
> >
> >
>
>
*Elmore, Andrew
Message 6 of 6 (54 Views)

Re:

08-06-2003 01:03 AM in reply to: *Elmore, Andrew
I have not tried this but.... maybe if I use more class libraries to
interface with acad then over comeing different version could be easier. So
if I had to classes 1 for 04 other for 3.3 then I could call into them to
get what I need.

imports ADT_class4
imports ADT_class3
imports AutoCAD

try
Dim Acad_con4 as new ADT_class4
Dim Acad_app3 as new ADT_class3
Dim Acad_app as AcadApplication
Dim Acad_doc as AcadDocument
try
Acad_app=Acad_con4.Application
catch
try
Acad_app=Acad_con3.Application
catch
msgbox("Did not work!")
end try
end try
Catch
end try

"Laurie Comerford" wrote in message
news:914024A6EE61D23528FAE9C425655CC9@in.WebX.maYIadrTaRb...
> Hi Andrew,
>
> I have been trying to resolve this issue in a desultary fashion for some
> time.
>
> The information below comes from the AUGI VBA Guild. It start with
Richard
> Binning providing information which I tried and I succeeded in loading the
> ALD libraries based on Richard's suggestions.
>
> However, I could not get my code to recognise that the libraries were
> loaded.
>
> The top message posted today by Ed Jobe in the AUGI VBA guild is my next
> port of call.
>
> I haven't had time to try Ed's suggestions yet, but the more of us that
try,
> the more likely we will be to get a working answer.
>
> Lastly, I have some information from Autodesk, that the process may be
> affected by a bug in the AutoCAD API's and for the moment it may not work
> anyhow with R2004.
> --
>
>
> Laurie Comerford
> CADApps
> www.cadapps.com.au
>
>
> ----- Original Message -----
> From: Ed Jobe
> To: guild-vba@augi.com
> Sent: Thursday, July 31, 2003 4:03 AM
> Subject: [VBA] Setting references programmatically
>
>
> A while back, someone asked how to set references programmatically, as
> in when you have different versions of a program you need to reference.
> The requestor was having trouble with the vbaide prompting to save the
> project after the reference was set. I just now had time to check into
> it. If you clean up after yourself, deleting the reference, you won't
> have this problem. I modified my functions to allow for this. I also
> added one to set the ref by GUID. That way you don't have to worry about
> checking for a valid file path. You can get the necessary GUID info
> using the sample sub below.
>
>
> Sub testref1()
> 'Sample to demonstrate working with references
> 'Set reference for ADO.
> '"Microsoft AcitveX Data Objects library 2.7"
> Dim objRef As vbide.Reference
> Set objRef = SetReferenceByFile("C:\Program Files\Common
> Files\system\ado\msado15.dll")
> ' Set objRef =
> SetReferenceByGUID("{EF53050B-882E-4776-B643-EDA472E8E3F2}", 2, 7)
> If objRef Is Nothing Then
> MsgBox Err.Number & ", " & Err.Description, vbExclamation,
> "Error setting reference."
> Else
> Debug.Print objRef.Guid & ", " & objRef.Major & ", " &
> objRef.Minor
> End If
> DeleteReference objRef
>
> End Sub
>
>
> Public Function DeleteReference(ref As vbide.Reference)
> On Error GoTo ErrorHandler
> Dim objVB As VBE
> Dim objRef As Reference
>
> Set objVB = Application.VBE
> objVB.ActiveVBProject.References.Remove ref
> GoTo Finish:
> ErrorHandler:
> MsgBox Err.Number & ", " & Err.Description, vbExclamation,
> "Error deleting reference."
> Finish:
> Set objVB = Nothing
> End Function
>
> Public Function SetReferenceByFile(filepath As String, Optional
> DisplayErrors As Boolean) As vbide.Reference
> 'Returns a Reference object if successful in setting a reference in
> the current dvb,
> 'given the FilePath of a tlb, olb, dll. The DisplayErrors option
> determines
> 'whether or not an error message will be displayed upon erroring.
> On Error GoTo ErrorHandler
> Dim objVB As VBE
> Dim objRef As vbide.Reference
> Dim objRefs As vbide.References
> Dim strPath As String
>
> Set objVB = Application.VBE
> Set objRef =
> objVB.ActiveVBProject.References.AddFromFile(filepath)
> Set SetReferenceByFile = objRef
> GoTo Finish:
> ErrorHandler:
> If Err.Number = 32813 Then
> 'reference was already set, just return True
> Set objRefs = objVB.ActiveVBProject.References
> For Each objRef In objRefs
> If objRef.FullPath = filepath Then
> Set SetReferenceByFile = objRef
> End If
> Next objRef
> Else
> If DisplayErrors = True Then
> MsgBox Err.Number & ", " & Err.Description, vbExclamation,
> "Error setting reference."
> Else
>
> End If
> Set SetReferenceByFile = Nothing
> End If
> Finish:
> Set objVB = Nothing
> Set objRef = Nothing
> End Function
>
> Public Function SetReferenceByGUID(strGUID As String, maj As Long, min
> As Long) As vbide.Reference
> 'Returns a Reference object if successful in setting a reference in
> the current dvb,
> 'given the GUID of a tlb, olb, dll. Using a GUID avoids having to
> test
> 'for a valid filepath.
> On Error GoTo ErrorHandler
> Dim objVB As VBE
> Dim objRef As vbide.Reference
> Dim strPath As String
>
> Set objVB = Application.VBE
> Set objRef = objVB.ActiveVBProject.References.AddFromGuid(strGUID,
> 1, 1)
> Set SetReferenceByGUID = objRef
> GoTo Finish:
> ErrorHandler:
> If Err.Number = 32813 Then
> 'reference was already set, just return True
> Set SetReferenceByGUID = objRef
> Else
> Set SetReferenceByGUID = Nothing
> End If
> Finish:
> Set objVB = Nothing
> Set objRef = Nothing
> End Function
>
> Ed Jobe
> guild-lisp-moderator@augi.com
> guild-mdt-moderator@augi.com
>
> ---footer---
> You are receiving this message because you are subscribed to
> guild-vba@augi.com. If you wish to unsubscribe from this list, please send
> an email to mailto:guild-vba-request@augi.com?Subject=unsubscribe with the
> word "unsubscribe" (without the quotes) in the subject of the email and
> follow any instructions that follow. If you require any help with
> subscription matters or general Guild information then please send an
email
> to mailto:guild-list-moderators@augi.com.
>
> ------------------------------------
>
> ----- Original Message -----
> From: Binning, Richard L.
> To: 'kdayman@UMAGroup.com' ; VBA Guild (guild-vba@augi.com)
> Sent: Wednesday, July 23, 2003 10:44 PM
> Subject: Re: [VBA] FW: Loading References when ALD but not Vanilla ACAD
>
>
> You can check the registry for the application that is running the macro.
> Check the "default" value of this key:
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
> Paths\acad.exe
>
> From the path to the executable, you should be able to detect what flavor
> the application
> is.
>
> You could also check the current profile with a function like that shown
> below:
>
> Function Get_ActiveProfile() As String
> ' This function returns the current setting of
> ' ActiveProfile.
> On Error Goto Err_Relief
> Dim preferences As AcadPreferences
> Dim currActiveProfile As String
> Set preferences = ThisDrawing.Application.preferences
> ' Retrieve the current ActiveProfile value
> currActiveProfile = preferences.Profiles.ActiveProfile
> Err_Relief:
> If Len(currActiveProfile) < 1 then
> msgbox "Error detected, profile unknown!"
> Else
> Get_ActiveProfile = currActiveProfile
> End if
> Set preferences = Nothing
> End Function
>
> To set a reference to a particular library, you will have to add a
reference
> to the microsoft vba extensibility 5.3 library.
> You can then declare some objects to hold the reference values such as:
>
> Dim oVBE As VBIDE.VBE
> Dim oVBP As VBIDE.VBProject
> Dim oVBPs as VBIDE.VBProjects
> Dim oVBR As VBIDE.Reference
> Dim oVBRs As VBIDE.References
>
> Now populate your objects...
>
> Set oVBE = Application.VBE
> Set oVBPs = oVBE.VBProjects
> Set oVBP = oVBPs("Your project title")
> Set oVBRs = oVBP.References
>
> You should be able to try attaching your desired ref here and do some
> trapping.
>
> On Error Resume Next
> Set oVBR = oVBRs("Your Type Library")
> If Err then
> 'clean it up
> else
> 'restore proper error handling here
> endif
>
>
> Does that give you enough to get started?
>
> P.S. I wrote that on the fly not in the VBA editor so I might have some
> error of exclusion or spelling.
>
>
>
>
> Richard Binning
>
> AUGI Guild Moderator
>
> AUGI Exchange Approvals Manager
>
> Member # 15067
>
> Win2k SP2
>
> Acad 2002
>
> Architectural Desktop 3.3 SP2
>
> Land Development Desktop 3.0
>
> Building Systems 3.0
>
> PIV 1.3 GHZ
>
> 512 RAM
>
> OXYGEN GVX1 32mb AGP
>
> Mailto: guild-cadmgr-moderator@augi.com
>
>
>
>
>
>
>
> > -----Original Message-----
> > From: Kelly Dayman (Bur) [mailto:kdayman@UMAGroup.com]
> > Sent: Tuesday, July 22, 2003 7:39 PM
> > To: VBA Guild (guild-vba@augi.com)
> > Subject: [VBA] FW: Loading References when ALD but not Vanilla ACAD
> >
> >
> >
> >
> > -----Original Message-----
> > From: Kelly Dayman (Bur)
> > Sent: Tuesday, July 22, 2003 4:28 PM
> > To: 'Wes Stueve'; Kelly Dayman (Bur)
> > Subject: RE: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > Thanks Wes, triggered some ideas but no result (stupid brain).
> > By big problem is how to load a reference at run time?
> >
> > Thanks,
> > Kelly
> >
> > -----Original Message-----
> > From: Wes Stueve [mailto:Wes.Stueve@hendersonengineers.com]
> > Sent: Tuesday, July 22, 2003 3:23 PM
> > To: kdayman@UMAGroup.com
> > Subject: RE: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > Which part fails? Does the AeccApplication application
> > object exist on
> > machines without ALD? If that is the case, you can say
> > (after removing the
> > reference):
> >
> > Dim obj
> >
> > On Error Resume Next
> >
> > Set obj = GetObject(,"[REFERENCELIB].AeccApplication")
> > If Err.Number <> 0 Then
> > 'it is not on this machine
> > End if
> >
> > The reference library should be able to be found in the
> > registry. Just do a
> > search for AeccApplication until you find something that
> > looks right. Look
> > at the GetObject and CreateObject functinons for help on
> > locating this.
> >
> > Don't know if this helps you or not, but good luck!
> >
> > Wes
> >
> > -----Original Message-----
> > From: Kelly Dayman (Bur) [mailto:kdayman@UMAGroup.com]
> > Sent: Tuesday, July 22, 2003 5:12 PM
> > To: 'Laurie Comerford'; Kelly Dayman (Bur); guild-vba@augi.com
> > Subject: Re: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> >
> > I want to only load the ALD Library if ALD is the application that is
> > running the VBA. However if I reference the library then try
> > to run on a
> > station that does not have ALD the VBA application gets very upset.
> >
> > I know this is possible I was involved in a thread that
> > discussed it about 4
> > months ago, however I have changed computers since then and I did not
> > transfer the info over. As soon as you get rid of something
> > you need it!!
> >
> > Kelly
> >
> > -----Original Message-----
> > From: Laurie Comerford [mailto:laurie@cadapps.com.au]
> > Sent: Tuesday, July 22, 2003 3:12 PM
> > To: kdayman@UMAGroup.com; guild-vba@augi.com
> > Subject: Re: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > Hi Kelly,
> >
> > I doubt that it would be legal for you to use ALD library
> > files on non-ALD AutoCADs.
> >
> > One way of dealing with the issue is to include the library
> > as a reference
> > in your program and then call the program with a lisp
> > function which checks
> > the AutoCAD version which is running and returns an error
> > message if it's
> > not ALD.
> >
> >
> > Laurie Comerford
> > CADApps
> > www.cadapps.com.au <>
> > ----- Original Message -----
> > From: Kelly Dayman (Bur)
> > To: VBA Guild (guild-vba@augi.com)
> > Sent: Wednesday, July 23, 2003 3:48 AM
> > Subject: [VBA] Loading References when ALD but not Vanilla ACAD
> >
> > I am working on a routine that will run on many different
> > platform ALD, ACAD
> > etc. When ALD is the current app I need to run the following
> > statement:
> >
> > AeccApplication.ActiveDocument.Preferences.databasescale = dblScale
> >
> > However I must load the associated Reference when in ALD in
> > order for this
> > to work, machines without ALD will not have this reference available.
> >
> > Reference Lib AUTODESK LAND 1.2 TYPR LIBRARY
> >
> > What is the best method to check if the app is ALD and load
> > the library in
> > the code?
> >
> > Kelly Dayman
> > UMA Group Ltd.
> >
> >
> ---footer---
> You are receiving this message because you are subscribed to
> guild-vba@augi.com. If you wish to unsubscribe from this list, please send
> an email to mailto:guild-vba-request@augi.com?Subject=unsubscribe with the
> word "unsubscribe" (without the quotes) in the subject of the email and
> follow any instructions that follow. If you require any help with
> subscription matters or general Guild information then please send an
email
> to mailto:guild-list-moderators@augi.com.
>
> -------------------------------------
>
> "Andrew Elmore" wrote in message
> news:997ECFDE9CB228122E33A8F6A95A7AB5@in.WebX.maYIadrTaRb...
> > How can I add references in my projects to work with ADT 3.3 and 04. I
use
> > 04 but some people are still useing 3.3 so I need both refs.
> >
> > Thanks,
> > Andy
> >
> >
>
>
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.