Help DLL calling in Excel 2007 crashes



This is going to sound weird and I have look for some help all over the net
to no avail.

I have an add-in which contains numerous VBA functions in it. One of these
functions calls a function in a DLL and when that DLL function returns, the
VBA continues executing by starting the same VBA function over. First off,
this call works perfectly in Excel 2002 & 2003. But in Excel 2007, the DLL
call causes the VBA function to restart to the top. Here is the declaration
of the DLL call:

Private Function EnablePrinter Lib "cdintf.dll" (ByVal hPrinter As Long,
ByRef szCompany As String, ByRef szCode As String) As Long

The VBA funtion is something like this:

Public Function ConvertPlain(ByVal XLSFilename, ByVal PrintToPrinterName As
String, ByVal Printer As Long, ByVal LicensedTo As String, ByVal
ActivationCode As String) As Integer
ConvertPlain = 1
Application.Workbooks.Open XLSFileName, 3, False
ActiveWorkbook.RunAutoMacros xlAutoOpen
With ActiveWorkBook
EnablePrinter(Printer, LicensedTo, ActivationCode)
.PrintOut ActivePrinter:=PrintToPrinterName
End With
End Function

So when the EnablePrinter function executes, the next line executing is
ConvertPlain = 1. Go figure.

Any help welcome
Wheeley
.



Relevant Pages

  • Re: Passing info between a DLL and an app
    ... problems executing dlls in Delphi. ... dll execution problems. ... RiseOrSetSw, passmmddyyyy: string): string; ... hDll: THandle; ...
    (alt.comp.lang.borland-delphi)
  • Re: Passing info between a DLL and an app
    ... problems executing dlls in Delphi. ... dll execution problems. ... RiseOrSetSw, passmmddyyyy: string): string; ... hDll: THandle; ...
    (alt.comp.lang.borland-delphi)
  • Re: Passing arguments from VBA to DLL
    ... I would assume it has to do with how VBA sends the string to your DLL. ... in a VBA function gives lstrlenAequal to 6. ...
    (microsoft.public.excel.programming)
  • Calling Methods in Sibling Class Module
    ... both in the same DLL. ... When executing a "write" method, ... string generated by "read" method. ... Somehow I figured out that if I add a .bas module with the line "Public ...
    (microsoft.public.vb.com)
  • Re: Explicit Linking of DLLs in VB.net
    ... yes this technique will only work on managed assemblys (exe or dll) ... "YourObject" is a form and is limited to the form methods. ... Wel implement propertys, methods, events in your interface and start ... Public Shared Function LoadMeByName(ByVal vstrAssemblyName As String, ...
    (microsoft.public.dotnet.languages.vb)