Help DLL calling in Excel 2007 crashes

W

Wheeley

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top