Author Topic: vba code works in 2004 but not in 2016  (Read 1200 times)

0 Members and 1 Guest are viewing this topic.

wjbzone

  • Newt
  • Posts: 30
vba code works in 2004 but not in 2016
« on: November 25, 2015, 02:31:04 pm »
I have a VBA program (LatLong.dvb) to convert coordinates from X,Y to Latitude,Longitude. It works fine in Autocad 2004 on my Windows 7 64 bit machine, but get an error in Autocad 2016. (using a calls to a DLL. )

(I installed the "AutoCAD_2016_AcVbaInstaller_Win_64bit_dlm.sfx.exe")

I also set my support File SearchPath to include the paths
   C:\LatLong
   C:\program files\corpscon6\


Below is the part of the code that I think may be my problem:

Module1 - General - Declarations:

#If VBA7 Then
Declare PtrSafe Function SetNadconPath Lib "c:\program files\corpscon6\corpscon_v6.dll" (ByVal path As String) As LongPtr
#Else
Declare Function GetNadconPath Lib "c:\program files\corpscon6\corpscon_v6.dll" (ByVal path As String) As Long
#End If


Module1 - General - convpts

Dim test7 As LongLong

test7 = SetNadconPath("c:\program files\corpscon6\nadcon")   'path to corpscon data files


The last line above causes this error:
Run-time error '48:
File not found c:\program files\corpscon6\corpscon_V6.dll


The corpscon_V6.dll is where it supposed to be, I don't know what else to try?

Please help.
Bill


MickD

  • Gator
  • Posts: 2883
  • I don't need a job, I need Money!!
Re: vba code works in 2004 but not in 2016
« Reply #1 on: November 25, 2015, 04:27:50 pm »
HI Bill, long time since I used vba but have you set the 'Reference' paths in your vba project to find the libraries you are using?
Or is that what you meant by support paths which I assumed your AutoCAD support paths?
"A language that doesn’t have everything is actually easier to program in than some that do."

        — Dennis M. Ritchie

n.yuan

  • Bull Frog
  • Posts: 214
Re: vba code works in 2004 but not in 2016
« Reply #2 on: November 26, 2015, 09:29:50 am »
As you might have already be aware of, this is very likely an issue of 32bit (Acad2004) and 64bit (Acad2016).

While you may think the #If directive would solve the issue by making the external function to return correct data type according to corresponding VBA version, it probably would not work because in your #If...#Else #End If, both branches point to the same DLL files, which unlikely be both 32-bit version and 64-bit version iin the same DLL file. It is either 32-bit, or 64-bit. For Acad2016 64-bit, you'll need 64-bit version of the said DLL.

wjbzone

  • Newt
  • Posts: 30
Re: vba code works in 2004 but not in 2016
« Reply #3 on: November 30, 2015, 09:31:35 am »
Thanks for the replies. The reference paths are right in my VBA program. I contacted the USACE (US Army Corp of Engineers) and they do not have a 64 bit version of the DLL.  I attempted to install the Autodesk 32bit VBA enabler for Autocad 2016, but that will not install on a 64 bit machine.  For now I'll just use 2004 when I want to use my program.

Thinking of a workaround using a Python and some temporary text files to do the conversion.