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

0 Members and 1 Guest are viewing this topic.

wjbzone

  • Guest
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

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
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?
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

n.yuan

  • Bull Frog
  • Posts: 348
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

  • Guest
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.

dhawk

  • Mosquito
  • Posts: 1
Re: vba code works in 2004 but not in 2016
« Reply #4 on: November 03, 2020, 05:57:22 PM »
There is a 64-bit version of this DLL available at https://github.com/dhawk/corpscon_v6_64bit.dll