2004 VBA not working in 2009

2004 VBA not working in 2009

David_Prontnicki
Collaborator Collaborator
265 Views
1 Reply
Message 1 of 2

2004 VBA not working in 2009

David_Prontnicki
Collaborator
Collaborator
Hey Guys,

I have a VBA that was orginally written in LDD 2004, the problem is when I try to run it in LDC 2009 it will not work.

When you try to run this all you get is "Land Desktop not Initialized - Initialize before continuing".

I understand that the structure has changed and the VBA needs to be updated to relect this. But being new to LDC 2009 I am not sure what the right coding is to change this to work.

I have attached the code for "one" of the modules and was hoping soemone could tell me what needs to be changed. I believe it has to do with the call to "AeccDatabasePreferences". I believe "Aecc" is not the call for in LDC 2009, but again being new to LDC 2009 I am not sure what it is now.

******Start Module Code**********

Public Function GetHScale() As Double

'Returns horizontal scale

On Error GoTo ErrHandling

Dim dbPref As AeccDatabasePreferences

Set dbPref = AeccApplication.ActiveDocument.Preferences

GetHScale = dbPref.DatabaseScale

GoTo GetOut

ErrHandling:
MsgBox "Land Desktop not Initialized - Initialize before continuing"
End

GetOut:
End Function
_____________________________________________________________

Public Function GetVScale() As Double

' Returns vertical scale

On Error GoTo ErrHandling
Dim dbPref As AeccDatabasePreferences

Set dbPref = AeccApplication.ActiveDocument.Preferences

GetVScale = dbPref.VerticalScale

GoTo GetOut

ErrHandling:
MsgBox "Land Desktop not Initialized - Initialize before continuing"
End

GetOut:

End Function
______________________________________________________________

Function Report_DatabaseScale()
Dim dbPref As AeccDatabasePreferences
Set dbPref = AeccApplication.ActiveDocument.Preferences
MsgBox (dbPref.DatabaseScale)
End Function
______________________________________________________________

Function WCStoUCSPoint(InPoint As Variant) As Variant
WCStoUCSPoint = ThisDrawing.Utility.TranslateCoordinates(InPoint, acWorld, acUCS, False)
End Function

******End Module Code**********

Thanks in advance!!!
0 Likes
266 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hi dprontnicki,

EVERY VBA program written to use Land Desktop functions is sensitive to
the version of Land Desktop and will not run in another version of Land
Desktop.

To change to another version, you have to open the program in the
VBAIDE, select [Tools][References] and change the libraries to match the
Land Desktop version you are using.

I about 95% of cases that is all you need do - other than the obvious
thing of saving the program under another name, so that it doesn't
overwrite the earlier version.

I use a naming system like:

"MyProgram R2004.dvb"
"MyProgram R2009.dvb"

Depending on what the program does there may be some changes and you
should run it on test data to check all is OK before using it.

It helps to check the program if you have "Option Explicit" at the top
of every module, form and class in the program, then use the
[Tools][Debug] command.

Regards


Laurie Comerford

dprontnicki wrote:
> Hey Guys, I have a VBA that was orginally written in LDD 2004, the
> problem is when I try to run it in LDC 2009 it will not work. When you
> try to run this all you get is "Land Desktop not Initialized -
> Initialize before continuing". I understand that the structure has
> changed and the VBA needs to be updated to relect this. But being new to
> LDC 2009 I am not sure what the right coding is to change this to work.
> I have attached the code for "one" of the modules and was hoping soemone
> could tell me what needs to be changed. I believe it has to do with the
> call to "AeccDatabasePreferences". I believe "Aecc" is not the call for
> in LDC 2009, but again being new to LDC 2009 I am not sure what it is
> now. ******Start Module Code********** Public Function
> GetHScale() As Double 'Returns horizontal scale On Error GoTo
> ErrHandling Dim dbPref As AeccDatabasePreferences Set dbPref =
> AeccApplication.ActiveDocument.Preferences GetHScale =
> dbPref.DatabaseScale GoTo GetOut ErrHandling: MsgBox "Land Desktop not
> Initialized - Initialize before continuing" End GetOut: End Function
> _____________________________________________________________ Public
> Function GetVScale() As Double ' Returns vertical scale On Error GoTo
> ErrHandling Dim dbPref As AeccDatabasePreferences Set dbPref =
> AeccApplication.ActiveDocument.Preferences GetVScale =
> dbPref.VerticalScale GoTo GetOut ErrHandling: MsgBox "Land Desktop not
> Initialized - Initialize before continuing" End GetOut: End Function
> ______________________________________________________________ Function
> Report_DatabaseScale() Dim dbPref As AeccDatabasePreferences Set dbPref
> = AeccApplication.ActiveDocument.Preferences MsgBox
> (dbPref.DatabaseScale) End Function
> ______________________________________________________________ Function
> WCStoUCSPoint(InPoint As Variant) As Variant WCStoUCSPoint =
> ThisDrawing.Utility.TranslateCoordinates(InPoint, acWorld, acUCS, False)
> End Function ******End Module Code********** Thanks in advance!!!
0 Likes