Home › Forums › HTBasic Forum › HTBDDE dll › Reply To: HTBDDE dll
January 6, 2024 at 2:53 pm
#9268
Hi ZeRider,
I put together a sample program and a sample excel file to try and reproduce the issue you are seeing above. I am able to consistently read all 200 rows of 259 cells. The difference could be in the data being read in since I am not certain the format of your data. Here is a link to the excel file I am using:
And here is my sample program:
my sample program:
CONFIGURE LONGFILENAMES ON
DLL UNLOAD ALL
LONG Hconvexcel! Excel conversation handle
LONG Retval ! Return value for the DLL functions
DLL LOAD "HTBdde"
DLL GET "LONG HTBdde:Ddeconnect"
DLL GET "SHORT HTBdde:Ddeterminate"
DLL GET "LONG HTBdde:Ddetimeout"
DLL GET "SHORT HTBdde:Ddeexecute"
DLL GET "SHORT HTBdde:Ddepoke"
DLL GET "CHARPTR HTBdde:Dderequest"
DLL GET "SHORT HTBdde:Runexe"
! Connect to the Excel System topic
Hconvexcel=FNDdeconnect("Excel","System")
IF Hconvexcel=0 THEN
! If we couldn't connect, lauch Excel and try again
Retval=FNRunexe("C:\Program Files\Microsoft Office\root\Office16\Excel.exe",1)
WAIT 2
Hconvexcel=FNDdeconnect("Excel","System")
! If we still couldn't connect, Exit
IF Hconvexcel=0 THEN
GOTO Exit
END IF
ELSE
! Create a new workbook
Retval=FNDdeexecute(Hconvexcel,"[Open(""C:\Program Files (x86)\HTBasic 2021\DLL Toolkit\Samples\HTBDde\sample.xlsx"")]")
IF NOT Retval THEN
PRINT "didn't open"
GOTO Exit
END IF !
END IF
IF Hconvexcel=0 THEN
GOTO Exit
END IF
DIM C$[20]
DIM Return$[50]
DIM Data$(1:200,1:259)[20]
Row$="L"
Total=0
FOR Line=1 TO 200
FOR Column=1 TO 259
C$=""
C$=Row$&VAL$(Line)&"C"&VAL$(Column)
Return$=""
Return$=FNDderequest$(Hconvexcel,C$)
Total=Total+1
Data$(Line,Column)=Return$
DISP Total,C$,Data$(Line,Column)
NEXT Column
NEXT Line
PRINT "Finished"
Exit:!
! Terminate the connection with Excel
IF (Hconvexcel) THEN
Retval=FNDdeterminate(Hconvexcel)!Terminate the excel DDE conversation
END IF
! Unload the DDE DLL
DLL UNLOAD "HTBdde"
END