VBA opens multiple files for processing.
Executable file (with VBA)
And, due to circumstances, only the A.xls file is closed during processing to free up memory.
However, for example, if there is a problem in the middle of processing, the error processing is skipped.Current situation
Even if there is a problem during the process and the error process is skipped,
The code that closes all files and frees memory at the end of processing.
However, for example, if you have trouble closing the A.xls file and skipping error processing
An error occurs in the code that closes the A.xls file and releases the memory.
'Close A.xls file (A.xls = SendFile) 'There is a closing process in the middle of the process. SendFile.Close SaveChanges: = True 'Processing when an error occurs 'Close A.xls file If SendFile.Name<>"" Then SendFile.Close SaveChanges: = True End If 'Error message MsgBox "Error in processing Capability Building ("&strError&")"&_ vbCrLf&"Error Number:"&Err.Number&_ vbCrLf&"Error description:"&Err.Description End Sub
The above part closes the A.xls file in the middle of processing.
If an error occurs after that,
'Close A.xls file If SendFile.Name<>"" Then SendFile.Close SaveChanges: = True End If
An error occurs in this part.
It seems that A.xls (= SendFile.Name) has already been closed.
In this case
① Determine if the file is open
② Close if open
, but I can't find that code.
Is there code that determines if a file is open?
Answer # 1
SendFile.Close Set SendFile = Nothing
As a matter of fact, in error processing, it can be closed if it is not Nothing.
Answer # 2
Wouldn't it be like this?
exists = False For Each wk In Workbooks If wk.Name = book name Then exists = True Exit For End If Next
Answer # 3
How about ignoring errors by writing
On Error Resume Nextbefore
- vba - i don't know how to import csv data with a macro
- i don't know how to save an image (jpg format) from a psd file
- [vba] i don't know how to log in automatically from the next time [keep login]
- i want to know how to use exit do with vba
- [vba] i don't know how to iterate
- i don't know how to read phpnet
- macos (osx) - i don't know how to use npm
- i don't know how to reflect css
- java - how to run jar file from shell
- vba - how to create a dataset
- python - i want to know how to keep outputting to csv
- c++ - i don't know how to use iterator it
- ios - i want to know how to switch view controllers
- php - i don't know how to pass the pass
- c++ - abc171e i don't know how to calculate xor
- i want to know how to modify the m file in gnu octave
- c# - i don't know how to get the title with cefsharp
- i want to know how to secure boot with esp32
- html - i don't know how to study programming
- how to resolve vba error messages (object required)
- i want to save a file using the urldownloadtofile function in excel vba, but the file is broken and it does not work
- vba - dir function open a file with an arbitrary number of digits using a wildcard
- Excel does not display pictures
- excel vba causes automation error when duplicating sheet
- how to transfer between conditional excel files using vba macros
- excel vba scraping cannot get the class under the class without id or name tag
- vba - i want to post from workbook to workbook with a macro, but i get the error message "the class does not support automa
- python - how to know the arguments of a vba function in a protected excel file
- how to post from workbook to workbook using vba macros