web-dev-qa-db-fra.com

Code VBA Excel: erreur de compilation dans la version x64 (attribut «PtrSafe» requis)

J'utilise Win8 x64 + Office 2013 x64.

MON PROBLÈME:

J'ai un fichier Excel, qui contient certains modules, et fonctionne parfaitement dans Office (Excel) x86. Il utilise le fichier Swiss Ephemeris ( swedll32.dll ) pour effectuer de nombreux calculs astronomiques.

Cependant, lorsque j'essaie de l'exécuter de mon côté, qui est sur Excel x64, dès qu'il est ouvert, l'éditeur VBA se déclenche et me donne l'erreur suivante:

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.

Comme je l'ai dit ci-dessus, cela ne fonctionne que dans le bureau 32 bits (Excel) mais cela ne fonctionnera pas dans mon Excel x64 Cependant, il semble y avoir une solution de contournement, mais je suis trop novice pour l'obtenir.

Je ne suis pas bon en VBA, cependant, après avoir creusé sur Internet, quelques sites Web ont proposé que pour le bureau 64 bits (Excel), nous devrions modifier (pour chaque déclaration) les codes en quelque chose comme ça:

  • Déclaration d'origine: fonction de déclaration privée
  • Déclaration modifiée: déclaration privée fonction PtrSafe

Malheureusement, après avoir ajouté " PtrSafe " partout, bien que les erreurs VBA se soient arrêtées, mais les valeurs ne sont pas affichées/calculées correctement dans les cellules.

D'après un article sur 64 bits en VBA de Microsoft, il semblerait que nous devions également modifier certains types de données tels que:

  • Long → à → LongPtr
  • LongPtr → à → LongLong
  • et certains "Long" sont censés rester les mêmes, selon ce qu'ils font.

Ce site Web (sous "Quels Longs devraient devenir LongPtr?") donne cependant un indice sur la façon de savoir lequel modifier.

Je n'y comprends rien et je n'ai aucune idée de ce qu'il faut vraiment faire pour que cela fonctionne dans Office (Excel) x64. Quelqu'un qui est assez bon dans ce domaine, veuillez m'aider. S'il vous plaît.

remarque:

  • Seules les déclarations apparaissant en rouge, indiquant qu'elles contiennent des erreurs, ont été vidées ici. La partie restante des codes n'a pas été collée ici car ils apparaissent fins (de couleur verte).
  • Pour que le fichier Excel fonctionne correctement sur votre ordinateur, assurez-vous que le "swedll32.dll" et le "JCalc Ver 0.2d.xls" se trouvent dans le même dossier, après les avoir extraits.

Problème dans le nom du module: 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 "_swe_azalt@40" ( _
      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 "_swe_azalt_rev@24" ( _
      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 "_swe_calc@24" ( _
      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 "_swe_calc_d@20" ( _
      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 "_swe_calc_ut@24" ( _
      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 "_swe_calc_ut_d@20" ( _
      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 "_swe_close@0" ( _
    ) As Long

Private Declare Function swe_close_d Lib "swedll32.dll" _
    Alias "_swe_close_d@4" ( _
      ByVal ivoid As Long _
    ) As Long       ' argument ivoid is ignored

Private Declare Sub swe_cotrans Lib "swedll32.dll" _
    Alias "_swe_cotrans@16" ( _
      ByRef xpo As Double, _
      ByRef xpn As Double, _
      ByVal eps As Double _
    )

Private Declare Function swe_cotrans_d Lib "swedll32.dll" _
    Alias "_swe_cotrans_d@12" ( _
      ByRef xpo As Double, _
      ByRef xpn As Double, _
      ByRef eps As Double _
    ) As Long

Private Declare Sub swe_cotrans_sp Lib "swedll32.dll" _
    Alias "_swe_cotrans_sp@16" ( _
      ByRef xpo As Double, _
      ByRef xpn As Double, _
      ByVal eps As Double _
    )

Private Declare Function swe_cotrans_sp_d Lib "swedll32.dll" _
    Alias "_swe_cotrans_sp_d@12" ( _
      ByRef xpo As Double, _
      ByRef xpn As Double, _
      ByRef eps As Double _
    ) As Long

Private Declare Sub swe_cs2degstr Lib "swedll32.dll" _
    Alias "_swe_cs2degstr@8" ( _
      ByVal t As Long, _
      ByVal S As String _
    )

Private Declare Function swe_cs2degstr_d Lib "swedll32.dll" _
    Alias "_swe_cs2degstr_d@8" ( _
      ByVal t As Long, _
      ByVal S As String _
    ) As Long

Private Declare Sub swe_cs2lonlatstr Lib "swedll32.dll" _
    Alias "_swe_cs2lonlatstr@16" ( _
      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 "_swe_cs2lonlatstr_d@16" ( _
      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_cs2timestr@16" ( _
      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 "_swe_cs2timestr_d@16" ( _
      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 "_swe_csnorm@4" ( _
      ByVal P As Long _
    ) As Long

Private Declare Function swe_csnorm_d Lib "swedll32.dll" _
    Alias "_swe_csnorm_d@4" ( _
      ByVal P As Long _
    ) As Long

Private Declare Function swe_csroundsec Lib "swedll32.dll" _
    Alias "_swe_csroundsec@4" ( _
      ByVal P As Long _
    ) As Long

Private Declare Function swe_csroundsec_d Lib "swedll32.dll" _
    Alias "_swe_csroundsec_d@4" ( _
      ByVal P As Long _
    ) As Long

Private Declare Function swe_d2l Lib "swedll32.dll" _
    Alias "_swe_d2l@8" ( _
    ) As Long

Private Declare Function swe_d2l_d Lib "swedll32.dll" _
    Alias "_swe_d2l_d@4" ( _
    ) As Long

Private Declare Function swe_date_conversion Lib "swedll32.dll" _
    Alias "_swe_date_conversion@28" ( _
      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 "_swe_date_conversion_d@24" ( _
      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 "_swe_day_of_week@8" ( _
      ByVal JD As Double _
    ) As Long

Private Declare Function swe_day_of_week_d Lib "swedll32.dll" _
    Alias "_swe_day_of_week_d@4" ( _
      ByRef JD As Double _
    ) As Long

Private Declare Function swe_degnorm Lib "swedll32.dll" _
    Alias "_swe_degnorm@8" ( _
      ByVal JD As Double _
    ) As Double

Private Declare Function swe_degnorm_d Lib "swedll32.dll" _
    Alias "_swe_degnorm_d@4" ( _
      ByRef JD As Double _
    ) As Long

Private Declare Function swe_deltat Lib "swedll32.dll" _
    Alias "_swe_deltat@8" ( _
      ByVal JD As Double _
    ) As Double

Private Declare Function swe_deltat_d Lib "swedll32.dll" _
    Alias "_swe_deltat_d@8" ( _
      ByRef JD As Double, _
      ByRef deltat As Double _
    ) As Long

Private Declare Function swe_difcs2n Lib "swedll32.dll" _
    Alias "_swe_difcs2n@8" ( _
      ByVal p1 As Long, _
      ByVal p2 As Long _
    ) As Long

Private Declare Function swe_difcs2n_d Lib "swedll32.dll" _
    Alias "_swe_difcs2n_d@8" ( _
      ByVal p1 As Long, _
      ByVal p2 As Long _
    ) As Long

Private Declare Function swe_difcsn Lib "swedll32.dll" _
    Alias "_swe_difcsn@8" ( _
      ByVal p1 As Long, _
      ByVal p2 As Long _
    ) As Long

Private Declare Function swe_difcsn_d Lib "swedll32.dll" _
    Alias "_swe_difcsn_d@8" ( _
      ByVal p1 As Long, _
      ByVal p2 As Long _
    ) As Long

Private Declare Function swe_difdeg2n Lib "swedll32.dll" _
    Alias "_swe_difdeg2n@16" ( _
      ByVal p1 As Double, _
      ByVal p2 As Double _
    ) As Double

Private Declare Function swe_difdeg2n_d Lib "swedll32.dll" _
    Alias "_swe_difdeg2n_d@12" ( _
      ByRef p1 As Double, _
      ByRef p2 As Double, _
      ByRef Diff As Double _
    ) As Long

Private Declare Function swe_difdegn Lib "swedll32.dll" _
    Alias "_swe_difdegn@16" ( _
      ByVal p1 As Double, _
      ByVal p2 As Double _
    ) As Long

Private Declare Function swe_difdegn_d Lib "swedll32.dll" _
    Alias "_swe_difdegn_d@12" ( _
      ByRef p1 As Double, _
      ByRef p2 As Double, _
      ByRef Diff As Double _
    ) As Long

Private Declare Function swe_fixstar Lib "swedll32.dll" _
    Alias "_swe_fixstar@24" ( _
      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 "_swe_fixstar_d@20" ( _
      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 "_swe_fixstar_ut@24" ( _
      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 "_swe_fixstar_ut_d@20" ( _
      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 "_swe_get_ayanamsa@8" ( _
      ByVal tjd_et As Double _
    ) As Double

Private Declare Function swe_get_ayanamsa_d Lib "swedll32.dll" _
    Alias "_swe_get_ayanamsa_d@8" ( _
      ByRef tjd_et As Double, _
      ByRef ayan As Double _
    ) As Long

Private Declare Function swe_get_ayanamsa_ut Lib "swedll32.dll" _
    Alias "_swe_get_ayanamsa_ut@8" ( _
      ByVal tjd_ut As Double _
    ) As Double

Private Declare Function swe_get_ayanamsa_ut_d Lib "swedll32.dll" _
    Alias "_swe_get_ayanamsa_ut_d@8" ( _
      ByRef tjd_ut As Double, _
      ByRef ayan As Double _
    ) As Long

Private Declare Sub swe_get_planet_name Lib "swedll32.dll" _
    Alias "_swe_get_planet_name@8" ( _
      ByVal ipl As Long, _
      ByVal pname As String _
    )

Private Declare Function swe_get_planet_name_d Lib "swedll32.dll" _
    Alias "_swe_get_planet_name_d@8" ( _
      ByVal ipl As Long, _
      ByVal pname As String _
    ) As Long

Private Declare Function swe_get_tid_acc Lib "swedll32.dll" _
    Alias "_swe_get_tid_acc@0" ( _
    ) As Double

Private Declare Function swe_get_tid_acc_d Lib "swedll32.dll" _
    Alias "_swe_get_tid_acc_d@4" ( _
      ByRef X As Double _
    ) As Long

Private Declare Function swe_houses Lib "swedll32.dll" _
    Alias "_swe_houses@36" ( _
      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 "_swe_houses_d@24" ( _
      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 "_swe_houses_ex@40" ( _
      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 "_swe_houses_ex_d@28" ( _
      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 "_swe_houses_armc@36" ( _
      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 "_swe_houses_armc_d@24" ( _
      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 "_swe_house_pos@36" ( _
      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 "_swe_house_pos_d@28" ( _
      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 "_swe_julday@24" ( _
      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 "_swe_julday_d@24" ( _
      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 "_swe_lun_Eclipse_how@24" ( _
      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 "_swe_lun_Eclipse_how_d@20" ( _
      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 "_swe_lun_Eclipse_when@28" ( _
      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 "_swe_lun_Eclipse_when_d@24" ( _
      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 "_swe_nod_aps@40" ( _
      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 "_swe_nod_aps_ut@40" ( _
      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 "_swe_pheno@24" ( _
      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 "_swe_pheno_ut@24" ( _
      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 "_swe_pheno_d@20" ( _
      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 "_swe_pheno_ut_d@20" ( _
      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 "_swe_refrac@28" ( _
      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 "_swe_revjul@28" ( _
      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 "_swe_revjul_d@24" ( _
      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 "_swe_rise_trans@52" ( _
      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 "_swe_set_ephe_path@4" ( _
      ByVal path As String _
    )

Private Declare Function swe_set_ephe_path_d Lib "swedll32.dll" _
    Alias "_swe_set_ephe_path_d@4" ( _
      ByVal path As String _
    ) As Long

Private Declare Sub swe_set_jpl_file Lib "swedll32.dll" _
    Alias "_swe_set_jpl_file@4" ( _
      ByVal file As String _
    )

Private Declare Function swe_set_jpl_file_d Lib "swedll32.dll" _
    Alias "_swe_set_jpl_file_d@4" ( _
      ByVal file As String _
    ) As Long

Private Declare Function swe_set_sid_mode Lib "swedll32.dll" _
    Alias "_swe_set_sid_mode@20" ( _
      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 "_swe_sid_mode_d@12" ( _
      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 "_swe_set_topo@24" ( _
      ByVal geolon As Double, _
      ByVal geolat As Double, _
      ByVal altitude As Double _
    )

Private Declare Function swe_set_topo_d Lib "swedll32.dll" _
    Alias "_swe_set_topo_d@12" ( _
      ByRef geolon As Double, _
      ByRef geolat As Double, _
      ByRef altitude As Double _
    )

Private Declare Sub swe_set_tid_acc Lib "swedll32.dll" _
    Alias "_swe_set_tid_acc@8" ( _
      ByVal X As Double _
    )

Private Declare Function swe_set_tid_acc_d Lib "swedll32.dll" _
    Alias "_swe_set_tid_acc_d@4" ( _
      ByRef X As Double _
    ) As Long

Private Declare Function swe_sidtime0 Lib "swedll32.dll" _
    Alias "_swe_sidtime0@24" ( _
      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 "_swe_sidtime0_d@16" ( _
      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 "_swe_sidtime@8" ( _
      ByVal tjd_ut As Double _
    ) As Double

Private Declare Function swe_sidtime_d Lib "swedll32.dll" _
    Alias "_swe_sidtime_d@8" ( _
      ByRef tjd_ut As Double, _
      ByRef sidt As Double _
    ) As Long

Private Declare Function swe_sol_Eclipse_how Lib "swedll32.dll" _
    Alias "_swe_sol_Eclipse_how@24" ( _
      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 "_swe_sol_Eclipse_how_d@20" ( _
      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 "_swe_sol_Eclipse_when_glob@28" ( _
      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 "_swe_sol_Eclipse_when_glob_d@24" ( _
      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 "_swe_sol_Eclipse_when_loc@32" ( _
      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 "_swe_sol_Eclipse_when_loc_d@28" ( _
      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 "_swe_sol_Eclipse_where@24" ( _
      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 "_swe_sol_Eclipse_where_d@20" ( _
      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 "_swe_time_equ@16" ( _
      ByVal tjd_ut As Double, _
      ByRef E As Double, _
      ByRef serr As String _
    ) As Long
25
user2422957

Je pense que tout ce que vous devez faire pour votre fonction est simplement d'ajouter PtrSafe: c'est-à-dire que la première ligne de votre première fonction devrait ressembler à ceci:

Fonction de déclaration privée PtrSafe swe_azalt Lib "swedll32.dll" ......
43
waweru

Je suis sûr que vous n'obtiendrez pas ce 32Bit DLL fonctionnant dans Office 64Bit. Le DLL doit être mis à jour par l'auteur pour être compatible avec 64Bit versions d'Office.

Les modifications de code que vous avez trouvées et fournies dans la question sont utilisées pour convertir les appels en API qui ont déjà été réécrites pour Office 64Bit. (La plupart des API Windows ont été mises à jour.)

De: http://technet.Microsoft.com/en-us/library/ee681792.aspx :

"Les contrôles ActiveX et les DLL de complément (COM) (bibliothèques de liens dynamiques) qui ont été écrits pour Office 32 bits ne fonctionneront pas dans un processus 64 bits."

Edit: Suite à votre commentaire, j'ai essayé la version 64Bit DLL version sur Win 8 64Bit avec Office 2010 64Bit . Puisque vous utilisez des fonctions définies par l'utilisateur appelées à partir de la feuille de calcul Excel, vous ne pouvez pas voir l'erreur renvoyée par Excel et vous retrouvez simplement avec le #VALUE revenu.

Si nous créons une procédure personnalisée dans VBA et essayons l'une des fonctions DLL, nous voyons l'erreur exacte renvoyée. J'ai essayé une fonction simple de swe_day_of_week qui a juste un temps en entrée et j'obtiens l'erreur Run-time error '48' File not found: swedll32.dll.

J'ai maintenant le 64Bit DLL que vous avez fourni aux bons emplacements, il doit donc être trouvé, ce qui suggère qu'il a des dépendances qui ne peuvent pas être localisées selon https://stackoverflow.com/a/8607250/1733206

J'ai tous les frameworks .NET installés, ce qui serait ma première supposition, donc sans plus d'informations de l'auteur, il pourrait être difficile de trouver le problème.

Edit2: Et après un peu plus de recherches, il apparaît que la version 64 bits que vous avez fournie est en fait une version 32 bits. D'où le message d'erreur sur le 64Bit Office. Vous pouvez le vérifier en essayant d'accéder à la version "64 bits" dans Office 32 bits.

2
CuberChase