Toon posts:

[VBA] Dll aanroep vanuit VBA...

Pagina: 1
Acties:

Verwijderd

Topicstarter
Hi,

Is het mogelijk om vanuit VBA (bv. Excel of Word of zo) een functie in een DLL (die ik zelf schrijf) aan te roepen? Zo ja, heeft iemand een voorbeeld?

alvast bedankt !!

  • Basszje
  • Registratie: Augustus 2000
  • Laatst online: 18-09 13:34

Basszje

Reisvaap!]

Kan dat niet gewoon met CreateObject ?

Beware of listening to the imposter; you are undone if you once forget that the fruits of the earth belong to us all, and the earth itself to nobody.


Verwijderd

Topicstarter
Moet ik niet ergens eerst de dll declaren?

  • Basszje
  • Registratie: Augustus 2000
  • Laatst online: 18-09 13:34

Basszje

Reisvaap!]

Op maandag 08 oktober 2001 09:29 schreef ScarFace_2000 het volgende:
Moet ik niet ergens eerst de dll declaren?
Ik vermoed van niet ( Ik ken VBA verder trouwens niet zo ) .

Maar probeer bv dit eens : Server.CreateObject("Word.Application") , als deze syntax werkt , probeer het dan met je eigen DLL naam ..

Beware of listening to the imposter; you are undone if you once forget that the fruits of the earth belong to us all, and the earth itself to nobody.


  • Gerco
  • Registratie: Mei 2000
  • Laatst online: 19-09 19:40

Gerco

Professional Newbie

Ja, dat kan.
code:
1
Public Declare Function naam(arg1,arg2) Lib "je.dll" As Returntype

Dan kun je gewoon naam(arg1,arg2) roepen in je code.

Deze syntax is voor 'gewone' (niet ActiveX) dll's. Voor ActiveX dll's moet je idd CreateObject oid gebruiken.

- "Als ik zou willen dat je het begreep, legde ik het wel beter uit!" | All number systems are base 10!


  • pjonk
  • Registratie: November 2000
  • Laatst online: 29-12-2025
Een DLL aanroepen vanuit VBA is heel simpel hoor.
Je dient eerst een referentie naar je DLL te hebben wat je in de editor kan instellen via Tools|References
(Je DLL moet uiteraard dan wel geregistreerd zijn)

Vervolgens zijn alle public classes van je DLL available en kan je daar gewoon met Dim X as New [ClassName] een instantie van maken.

Dit werkt inderdaad wel alleen met ActiveX/COM DLL's

It’s nice to be important but it’s more important to be nice


Verwijderd

Topicstarter
Op maandag 08 oktober 2001 11:50 schreef Gerco het volgende:
Ja, dat kan.
code:
1
Public Declare Function naam(arg1,arg2) Lib "je.dll" As Returntype

Dan kun je gewoon naam(arg1,arg2) roepen in je code.

Deze syntax is voor 'gewone' (niet ActiveX) dll's. Voor ActiveX dll's moet je idd CreateObject oid gebruiken.
Oke. bedankt ! Dit was de oplossing die ik zocht !
Pagina: 1