Hi all;
What I want to do is; to embed a DLL file into the worksheet and then export the DLL file to harddisk when needed.
I have imported the DLL file into the sheet by reading each byte and writing into the cells. It takes about 5 minutes to complete the process. Btw, the imported DLL file size is about 3 MB. (i.e. almost 3 columns of the sheet are full)
So far, this part of the job is nearly OK ...
Then, I export the DLL file by reading from the cells that have been written before ... by the code given below. But it takes about 2 hours to complete the job
The code has Application.ScreenUpdating = True for now, just to see the progress going on which is shown in cell M1 formatted as "%"
I want to know if there is any other method to speed up the process....
The code for exporting the data is;
Sub Export_DLL()
Dim i As Long, NoA As Long
Dim FreeNum As Long
Dim Time1 As Date, Time2 As Date
Dim LOF_DLL As Long, r As Long
Time1 = Now
TempFile = ThisWorkbook.Path & Application.PathSeparator & "ExportedDLL_HD.dll"
LastCol = Cells(2, Columns.Count).End(xlToLeft).Column
LastColRow = Cells(Rows.Count, LastCol).End(xlUp).Row
LOF_DLL = (LastCol - 1) * (Rows.Count - 2) + (LastColRow - 1)
FreeNum = FreeFile
' Application.ScreenUpdating = False
For j = 1 To LastCol
NoA = Sheets("Imported_DLL").Cells(Rows.Count, j).End(xlUp).Row
For i = 2 To NoA
r = r + 1
TempData = TempData & Chr(Sheets("Imported_DLL").Cells(i, j))
DoEvents
Range("M1") = (r / LOF_DLL)
Next
Next
Open TempFile For Output As #FreeNum
Print #FreeNum, TempData
Close FreeNum
' Application.ScreenUpdating = True
Time2 = Now
timeElapsed = Format(Time2 - Time1, "hh:mm:ss,ms")
MsgBox "Exporting is finnished" & vbCrLf & "Time elapsed: " & timeElapsed
End Sub
.
Bookmarks