Код Excel VBA: ошибка компиляции в версии x64 (требуется атрибут «PtrSafe»)

Я использую Win8 x64 + Office 2013 x64.

МОЯ ПРОБЛЕМА:

У меня есть файл excel, в котором есть некоторые модули, и работает безупречно в Office (Excel) x86. Он использует файл Swiss Ephemeris ( swedll32.dll ), чтобы выполнить множество астрономических вычислений.

Однако, когда я пытаюсь запустить его на своем конце, который находится на Excel x64, ASAP открывается, редактор VBA запускается и дает мне следующую ошибку:

Compile error: The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PtrSafe attribute. 

Как я сказал выше, он работает только в 32-битном офисе (Excel), но он не будет работать в моем x64 Excel. Однако, похоже, это обходное решение, но я слишком много начинающего, чтобы его получить.

Однако я не очень хорош в VBA, после того, как выкапывали через Интернет, несколько веб-сайтов предложили, что для 64-битного офиса (Excel) мы должны изменить (для каждой декларации) коды на что-то вроде этого:

  • Оригинальное заявление: функция Private Declare
  • Измененное заявление: Private Declare Функция PtrSafe

К сожалению, после добавления « PtrSafe » повсюду, хотя ошибки VBA прекратились, но значения не отображаются / правильно вычисляются в ячейках.

Из сообщения в 64-битной версии VBA от Microsoft кажется, что нам также необходимо изменить некоторые типы данных, такие как:

  • Long → to → LongPtr
  • LongPtr → to → LongLong
  • и некоторые «Длинные» должны оставаться неизменными, в зависимости от того, что они делают.

Этот веб-сайт (в разделе «Какие долги должны стать LongPtr?») Дает ключ к пониманию того, как узнать, какой из них изменить.

Я ничего не понимаю об этом и понятия не имею, что делать, чтобы сделать эту работу в Office (Excel) x64. Кто-то, кто очень хорош в этом, любезно, пожалуйста, помогите мне. Пожалуйста.

заметка:

  • Здесь были сброшены только те объявления, которые появились красным цветом, обозначая, что они содержат ошибки. Оставшаяся часть кодов не была вставлена ​​здесь, потому что они выглядят прекрасно (зеленый цвет). Если вы хотите посмотреть файл, файл можно скачать здесь: http://bit.ly/Z8Kqm9
  • Чтобы файл Excel работал правильно на вашем компьютере, убедитесь, что «swedll32.dll» и «JCalc Ver 0.2d.xls» находятся в одной папке после их извлечения.

Проблема в имени модуля: MainCalculations

 'Swiss Ephemeris Release 1.60 9-jan-2000 ' ' Declarations for Visual Basic 5.0 ' The DLL file must exist in the same directory, or in a system ' directory where it can be found at runtime ' Private Declare Function swe_azalt Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal calc_flag As Long, _ ByRef geopos As Double, _ ByVal atpress As Double, _ ByVal attemp As Double, _ ByRef xin As Double, _ ByRef xaz As Double _ ) As Long 'geopos must be the first of three array elements 'xin must be the first of two array elements 'xaz must be the first of three array elements Private Declare Function swe_azalt_rev Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal calc_flag As Long, _ ByRef geopos As Double, _ ByRef xin As Double, _ ByRef xout As Double _ ) As Long 'geopos must be the first of three array elements 'xin must be the first of two array elements 'xout must be the first of three array elements Private Declare Function swe_calc Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes Private Declare Function swe_calc_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes Private Declare Function swe_calc_ut Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes Private Declare Function swe_calc_ut_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes Private Declare Function swe_close Lib "swedll32.dll" _ Alias "[email protected]" ( _ ) As Long Private Declare Function swe_close_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal ivoid As Long _ ) As Long ' argument ivoid is ignored Private Declare Sub swe_cotrans Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef xpo As Double, _ ByRef xpn As Double, _ ByVal eps As Double _ ) Private Declare Function swe_cotrans_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef xpo As Double, _ ByRef xpn As Double, _ ByRef eps As Double _ ) As Long Private Declare Sub swe_cotrans_sp Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef xpo As Double, _ ByRef xpn As Double, _ ByVal eps As Double _ ) Private Declare Function swe_cotrans_sp_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef xpo As Double, _ ByRef xpn As Double, _ ByRef eps As Double _ ) As Long Private Declare Sub swe_cs2degstr Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal t As Long, _ ByVal S As String _ ) Private Declare Function swe_cs2degstr_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal t As Long, _ ByVal S As String _ ) As Long Private Declare Sub swe_cs2lonlatstr Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal t As Long, _ ByVal pchar As Byte, _ ByVal mchar As Byte, _ ByVal S As String _ ) Private Declare Function swe_cs2lonlatstr_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal t As Long, _ ByRef pchar As Byte, _ ByRef mchar As Byte, _ ByVal S As String _ ) As Long Private Declare Sub swe_cs2timestr Lib "swedll32.dll" _ Alias "_swe_cs2ti[email protected]" ( _ ByVal t As Long, _ ByVal sep As Long, _ ByVal supzero As Long, _ ByVal S As String _ ) Private Declare Function swe_cs2timestr_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal t As Long, _ ByVal sep As Long, _ ByVal supzero As Long, _ ByVal S As String _ ) As Long Private Declare Function swe_csnorm Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal P As Long _ ) As Long Private Declare Function swe_csnorm_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal P As Long _ ) As Long Private Declare Function swe_csroundsec Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal P As Long _ ) As Long Private Declare Function swe_csroundsec_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal P As Long _ ) As Long Private Declare Function swe_d2l Lib "swedll32.dll" _ Alias "[email protected]" ( _ ) As Long Private Declare Function swe_d2l_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ) As Long Private Declare Function swe_date_conversion Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal Year As Long, _ ByVal Month As Long, _ ByVal Day As Long, _ ByVal utime As Double, _ ByVal cal As Byte, _ ByRef tjd As Double _ ) As Long Private Declare Function swe_date_conversion_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal Year As Long, _ ByVal Month As Long, _ ByVal Day As Long, _ ByRef utime As Double, _ ByRef cal As Byte, _ ByRef tjd As Double _ ) As Long Private Declare Function swe_day_of_week Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal JD As Double _ ) As Long Private Declare Function swe_day_of_week_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef JD As Double _ ) As Long Private Declare Function swe_degnorm Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal JD As Double _ ) As Double Private Declare Function swe_degnorm_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef JD As Double _ ) As Long Private Declare Function swe_deltat Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal JD As Double _ ) As Double Private Declare Function swe_deltat_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef JD As Double, _ ByRef deltat As Double _ ) As Long Private Declare Function swe_difcs2n Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal p1 As Long, _ ByVal p2 As Long _ ) As Long Private Declare Function swe_difcs2n_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal p1 As Long, _ ByVal p2 As Long _ ) As Long Private Declare Function swe_difcsn Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal p1 As Long, _ ByVal p2 As Long _ ) As Long Private Declare Function swe_difcsn_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal p1 As Long, _ ByVal p2 As Long _ ) As Long Private Declare Function swe_difdeg2n Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal p1 As Double, _ ByVal p2 As Double _ ) As Double Private Declare Function swe_difdeg2n_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef p1 As Double, _ ByRef p2 As Double, _ ByRef Diff As Double _ ) As Long Private Declare Function swe_difdegn Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal p1 As Double, _ ByVal p2 As Double _ ) As Long Private Declare Function swe_difdegn_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef p1 As Double, _ ByRef p2 As Double, _ ByRef Diff As Double _ ) As Long Private Declare Function swe_fixstar Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal star As String, _ ByVal tjd As Double, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes ' star must be able to hold 40 bytes Private Declare Function swe_fixstar_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal star As String, _ ByRef tjd As Double, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes ' star must be able to hold 40 bytes Private Declare Function swe_fixstar_ut Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal star As String, _ ByVal tjd_ut As Double, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes ' star must be able to hold 40 bytes Private Declare Function swe_fixstar_ut_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal star As String, _ ByRef tjd_ut As Double, _ ByVal iflag As Long, _ ByRef X As Double, _ ByVal serr As String _ ) As Long ' x must be first of six array elements ' serr must be able to hold 256 bytes ' star must be able to hold 40 bytes Private Declare Function swe_get_ayanamsa Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_et As Double _ ) As Double Private Declare Function swe_get_ayanamsa_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_et As Double, _ ByRef ayan As Double _ ) As Long Private Declare Function swe_get_ayanamsa_ut Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double _ ) As Double Private Declare Function swe_get_ayanamsa_ut_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByRef ayan As Double _ ) As Long Private Declare Sub swe_get_planet_name Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal ipl As Long, _ ByVal pname As String _ ) Private Declare Function swe_get_planet_name_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal ipl As Long, _ ByVal pname As String _ ) As Long Private Declare Function swe_get_tid_acc Lib "swedll32.dll" _ Alias "[email protected]" ( _ ) As Double Private Declare Function swe_get_tid_acc_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef X As Double _ ) As Long Private Declare Function swe_houses Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal geolat As Double, _ ByVal geolon As Double, _ ByVal ihsy As Long, _ ByRef hcusps As Double, _ ByRef ascmc As Double _ ) As Long ' hcusps must be first of 13 array elements ' ascmc must be first of 10 array elements Private Declare Function swe_houses_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByRef geolat As Double, _ ByRef geolon As Double, _ ByVal ihsy As Long, _ ByRef hcusps As Double, _ ByRef ascmc As Double _ ) As Long ' hcusps must be first of 13 array elements ' ascmc must be first of 10 array elements Private Declare Function swe_houses_ex Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal iflag As Long, _ ByVal geolat As Double, _ ByVal geolon As Double, _ ByVal ihsy As Long, _ ByRef hcusps As Double, _ ByRef ascmc As Double _ ) As Long ' hcusps must be first of 13 array elements ' ascmc must be first of 10 array elements Private Declare Function swe_houses_ex_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByVal iflag As Long, _ ByRef geolat As Double, _ ByRef geolon As Double, _ ByVal ihsy As Long, _ ByRef hcusps As Double, _ ByRef ascmc As Double _ ) As Long ' hcusps must be first of 13 array elements ' ascmc must be first of 10 array elements Private Declare Function swe_houses_armc Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal armc As Double, _ ByVal geolat As Double, _ ByVal eps As Double, _ ByVal ihsy As Long, _ ByRef hcusps As Double, _ ByRef ascmc As Double _ ) As Long ' hcusps must be first of 13 array elements ' ascmc must be first of 10 array elements Private Declare Function swe_houses_armc_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef armc As Double, _ ByRef geolat As Double, _ ByRef eps As Double, _ ByVal ihsy As Long, _ ByRef hcusps As Double, _ ByRef ascmc As Double _ ) As Long ' hcusps must be first of 13 array elements ' ascmc must be first of 10 array elements Private Declare Function swe_house_pos Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal armc As Double, _ ByVal geolat As Double, _ ByVal eps As Double, _ ByVal ihsy As Long, _ ByRef xpin As Double, _ ByVal serr As String _ ) As Double ' xpin must be first of 2 array elements Private Declare Function swe_house_pos_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef armc As Double, _ ByRef geolat As Double, _ ByRef eps As Double, _ ByVal ihsy As Long, _ ByRef xpin As Double, _ ByRef hpos As Double, _ ByVal serr As String _ ) As Long ' xpin must be first of 2 array elements Private Declare Function swe_julday Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal Year As Long, _ ByVal Month As Long, _ ByVal Day As Long, _ ByVal hour As Double, _ ByVal gregflg As Long _ ) As Double Private Declare Function swe_julday_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal Year As Long, _ ByVal Month As Long, _ ByVal Day As Long, _ ByRef hour As Double, _ ByVal gregflg As Long, _ ByRef tjd As Double _ ) As Long Private Declare Function swe_lun_eclipse_how Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal ifl As Long, _ ByRef geopos As Double, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_lun_eclipse_how_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByVal ifl As Long, _ ByRef geopos As Double, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_lun_eclipse_when Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_start As Double, _ ByVal ifl As Long, _ ByVal ifltype As Long, _ ByRef tret As Double, _ ByVal backward As Long, _ ByVal serr As String _ ) As Long Private Declare Function swe_lun_eclipse_when_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_start As Double, _ ByVal ifl As Long, _ ByVal ifltype As Long, _ ByRef tret As Double, _ ByVal backward As Long, _ ByVal serr As String _ ) As Long Private Declare Function swe_nod_aps Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_et As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByVal method As Long, _ ByRef xnasc As Double, _ ByRef xndsc As Double, _ ByRef xperi As Double, _ ByRef xaphe As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_nod_aps_ut Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByVal method As Long, _ ByRef xnasc As Double, _ ByRef xndsc As Double, _ ByRef xperi As Double, _ ByRef xaphe As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_pheno Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_pheno_ut Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_pheno_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_pheno_ut_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd As Double, _ ByVal ipl As Long, _ ByVal iflag As Long, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_refrac Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal inalt As Double, _ ByVal atpress As Double, _ ByVal attemp As Double, _ ByVal calc_flag As Long _ ) As Double Private Declare Sub swe_revjul Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd As Double, _ ByVal gregflg As Long, _ ByRef Year As Long, _ ByRef Month As Long, _ ByRef Day As Long, _ ByRef hour As Double _ ) Private Declare Function swe_revjul_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd As Double, _ ByVal gregflg As Long, _ ByRef Year As Long, _ ByRef Month As Long, _ ByRef Day As Long, _ ByRef hour As Double _ ) As Long Private Declare Function swe_rise_trans Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal ipl As Long, _ ByVal starname As String, _ ByVal epheflag As Long, _ ByVal rsmi As Long, _ ByRef geopos As Double, _ ByVal atpress As Double, _ ByVal attemp As Double, _ ByRef tret As Double, _ ByVal serr As String _ ) As Long Private Declare Sub swe_set_ephe_path Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal path As String _ ) Private Declare Function swe_set_ephe_path_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal path As String _ ) As Long Private Declare Sub swe_set_jpl_file Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal file As String _ ) Private Declare Function swe_set_jpl_file_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal file As String _ ) As Long Private Declare Function swe_set_sid_mode Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal sid_mode As Long, _ ByVal t0 As Double, _ ByVal ayan_t0 As Double _ ) As Long Private Declare Function swe_set_sid_mode_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal sid_mode As Long, _ ByRef t0 As Double, _ ByRef ayan_t0 As Double _ ) As Long Private Declare Function swe_set_topo Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal geolon As Double, _ ByVal geolat As Double, _ ByVal altitude As Double _ ) Private Declare Function swe_set_topo_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef geolon As Double, _ ByRef geolat As Double, _ ByRef altitude As Double _ ) Private Declare Sub swe_set_tid_acc Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal X As Double _ ) Private Declare Function swe_set_tid_acc_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef X As Double _ ) As Long Private Declare Function swe_sidtime0 Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal ecl As Double, _ ByVal nut As Double _ ) As Double Private Declare Function swe_sidtime0_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByRef ecl As Double, _ ByRef nut As Double, _ ByRef sidt As Double _ ) As Long Private Declare Function swe_sidtime Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double _ ) As Double Private Declare Function swe_sidtime_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByRef sidt As Double _ ) As Long Private Declare Function swe_sol_eclipse_how Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal ifl As Long, _ ByRef geopos As Double, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_sol_eclipse_how_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByVal ifl As Long, _ ByRef geopos As Double, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_sol_eclipse_when_glob Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_start As Double, _ ByVal ifl As Long, _ ByVal ifltype As Long, _ ByRef tret As Double, _ ByVal backward As Long, _ ByVal serr As String _ ) As Long Private Declare Function swe_sol_eclipse_when_glob_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_start As Double, _ ByVal ifl As Long, _ ByVal ifltype As Long, _ ByRef tret As Double, _ ByVal backward As Long, _ ByVal serr As String _ ) As Long Private Declare Function swe_sol_eclipse_when_loc Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_start As Double, _ ByVal ifl As Long, _ ByRef tret As Double, _ ByRef attr As Double, _ ByVal backward As Long, _ ByVal serr As String _ ) As Long Private Declare Function swe_sol_eclipse_when_loc_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_start As Double, _ ByVal ifl As Long, _ ByRef tret As Double, _ ByRef attr As Double, _ ByVal backward As Long, _ ByVal serr As String _ ) As Long Private Declare Function swe_sol_eclipse_where Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByVal ifl As Long, _ ByRef geopos As Double, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_sol_eclipse_where_d Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByRef tjd_ut As Double, _ ByVal ifl As Long, _ ByRef geopos As Double, _ ByRef attr As Double, _ ByVal serr As String _ ) As Long Private Declare Function swe_time_equ Lib "swedll32.dll" _ Alias "[email protected]" ( _ ByVal tjd_ut As Double, _ ByRef E As Double, _ ByRef serr As String _ ) As Long 

Я думаю, что все, что вам нужно сделать для вашей функции, это просто добавить PtrSafe: т.е. первая строка вашей первой функции должна выглядеть так:

  Private Declare PtrSafe Функция swe_azalt Lib "swedll32.dll" ...... 

Я уверен, что вы не получите эту 32Bit DLL, работающую в Office 64Bit. DLL должен быть обновлен автором для совместимости с 64-битными версиями Office.

Изменения кода, которые вы нашли и поставили в вопросе, используются для преобразования вызовов в API, которые уже были переписаны для Office 64Bit. (Большинство Windows API были обновлены.)

От: http://technet.microsoft.com/en-us/library/ee681792.aspx :

«Элементы ActiveX и надстройки (COM) DLL (библиотеки динамических ссылок), которые были написаны для 32-разрядного Office, не будут работать в 64-разрядном процессе».

Изменить: в дополнение к вашему комментарию, я пробовал версию 64Bit DLL на Win 8 64Bit с Office 2010 64Bit. Поскольку вы используете пользовательские функции, вызываемые из листа Excel, вы не можете увидеть ошибку, #VALUE Excel, и просто #VALUE .

Если мы создадим пользовательскую процедуру в VBA и попробуем одну из функций DLL, мы увидим точную ошибку. Я пробовал простую функцию swe_day_of_week которая просто имеет время ввода, и я получаю ошибку. Run-time error '48' File not found: swedll32.dll .

Теперь у меня есть 64Bit DLL, которую вы поставили в правильных местах, поэтому нужно найти, что предполагает наличие зависимостей, которые не могут быть расположены по https://stackoverflow.com/a/8607250/1733206

У меня установлены все платформы .NET, которые были бы моей первой догадкой, поэтому без дополнительной информации от автора было бы трудно найти проблему.

Edit2: И после немного более тщательного изучения появляется версия 64Bit, которую вы поставили, на самом деле является 32-битной версией. Следовательно, сообщение об ошибке в 64Bit Office. Вы можете проверить это, пытаясь получить доступ к версии 64Bit в Office 32Bit.

  • Получение ошибки выполнения 91
  • excel vba insert run error error 1004
  • Назначить макрос кнопке, созданной во время выполнения VBA
  • Сравнение значений времени в VBA бросает ошибку времени выполнения 13 'несоответствие типа'
  • Excel 2007 - 1004 Ошибка времени выполнения Обновить таблицу запросов
  • Excel VBA: ошибка времени выполнения 7: вне памяти
  • VBA в ошибке выполнения функции поиска 91
  • Объект файловой системы Excel VBA
  • Ошибка времени выполнения VBA 13: несоответствие типов
  • Ошибка времени выполнения 1004 Невозможно вставить новые ячейки, потому что они будут выталкивать непустые новые ячейки с конца рабочего листа
  • Ссылка на командные кнопки, добавленные во время выполнения с VBA в Excel
  • Interesting Posts

    Импорт нескольких изображений в excel при сохранении пропорций

    Эффективные способы хранения нескольких файлов excel в базе данных?

    Как установить поля Excel с помощью EPPlus

    Формат диапазона Excel: номер автоматически отформатируется, когда Range :: Value2 установлен

    код сортировки excel, вызывающий коррупцию

    События VBA SendKey происходят из-за заказа

    Excel: если какое-либо поле в строке не равно NULL, установите ячейку в первом столбце в число с добавочным номером?

    COUNTA и INDIRECT вместе

    Средняя функция google sheets

    Excel VBA, чтобы открыть сайт интрасети, и найдите конкретное имя ссылки, а затем нажмите

    Выбрать / Изменить / Ввести блоки (по вертикали) текста в MS Word / Excel

    Граница вокруг динамического диапазона

    Ошибка приложения 424 приложения. Ошибка

    Как дать множественный цвет в одной ячейке, если он содержит формулы в excel

    Как закодировать код VBA для выполнения тех же действий через список данных

    Давайте будем гением компьютера.