View Single Post
 
Old 10-13-2023, 01:02 AM
ArviLaanemets ArviLaanemets is offline Windows 8 Office 2016
Expert
 
Join Date: May 2017
Posts: 932
ArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant future
Default

The crashing was caused by exessive 'Exit For' in my code. I divided my script into separate blocks to lessen the amount of nestings - so now I have better overview of them!

Also I now open the every source file I read the data from in a separate instance, and close it after the data are read and processed. Like:
Code:
...
Dim oInst As Object
...
For strSourceNameRow = 1 To NumberOfSourceFiles
        strSourceFile = <full path for source file to be opened>
        Set oInst = GetObject(strSourceFile)
...
        GoTo ExitSourceNameRow
...
ExitSourceNameRow:
        ' Activate the converter file, and Close the source file
        Workbooks(strSourceFileName).Activate
        Workbooks(strSourceFileName).Close savechanges:=False
        oInst.Close
        Set oInst = Nothing
        Workbooks(strThisFile).Activate
...
Reply With Quote