I'm trying to implement the OCI in Excel VBA with my end goal of using OCIPasswordChange from an Excel form after the user's password has expired; however my progress has been a bit slow and I was wondering if someone else out there had already blazed this trail and/or if I could get some general advice on the following issue:

My System Setup: Win7 64-bit, Oracle Thick Client 11.2.0 32-bit, MS Office 2013 32-bit, both Windows ODBC and SQL*Plus are connecting to the oracle server and working properly.

The following C code snipit I'm trying to bend to VBA came from: http://database.developer-works.com/...nge+call+in+8i
// Step 1: Initialize OCI
rc = OCIInitialize((ub4) OCI_DEFAULT, // 0x00000000
                   (dvoid *)0,        // udef call back for mem context routines
                   (dvoid * (*)(dvoid *, size_t)) 0,
                   (dvoid * (*)(dvoid *, dvoid *, size_t))0,
                   (void (*)(dvoid *, dvoid *)) 0 );
if(rc != 0) oerr();
Which I've ported to Excel VBA as: (Warning causes Excel to crash!)
Private Const OCI_DEFAULT As Long = &H0

Private Declare Function OCIinit Lib "OCI.DLL" Alias "OCIInitialize" ( _
    ByVal lMode As Long, ByVal pvCtxp As Any, pfnMalocfp As Any, pfnRalocfp As Any, pfnMfreefp As Any _
    ) As Long

Private Sub tst()
    Dim RetCode As Long
    Dim ctx As Long, maloc As Long, raloc As Long, mfree As Long
    ctx = 0: maloc = 0: raloc = 0: mfree = 0
    RetCode = OCIinit(OCI_DEFAULT, ctx, maloc, raloc, mfree)
    MsgBox RetCode
End Sub
The "manual" I found online for OCIInitialize is here: http://docs.oracle.com/cd/B10501_01/...re7.htm#556332

The problem I'm getting with the above VBA code is that when I run it Excel crashes, and when I go to the windows event viewer it's giving an "Exception code: 0xc0000005" which is for an access violation. Looking into oracle's "oratypes.h" file gives "#define dvoid void" and "#define ub4 unsigned int".

So did I port the four void functions:
  • (dvoid *)0
  • (dvoid * (*)(dvoid *, size_t)) 0
  • (dvoid * (*)(dvoid *, dvoid *, size_t))0
  • (void (*)(dvoid *, dvoid *)) 0 )

correctly from C, or am I missing something here?

I can't really tell if the access violation is due to OCIInitialize trying to call back into Excel's space or if I've done the Null function pointers wrong.

Any insights would be appriciated, thank you.