ABSOLUTELY! That's what the Excel component does for you: It kills and restarts the MSWord job.
get that MSWord piece in action, hunting for DOC files until it baulks, and then I'll test and ship you the Excel module.
Cheers, Chris
ABSOLUTELY! That's what the Excel component does for you: It kills and restarts the MSWord job.
I completely understand a reluctance to post a file publicly. As an example, If my Password.doc file was corrupt, I'd be reluctant to post it Eileen's Lounge (my home-away-from-home) for debugging.
Try this:
Code: Select all
Application.Wait (Now + TimeValue("0:00:2"))
CreateObject("WScript.Shell").SendKeys "{ENTER}", True
Code: Select all
Opt('WinWaitDelay', 250)
Opt('WinDetectHiddenText', 1)
Opt('MouseCoordMode', 1)
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("SendKeyDelay", 50)
Opt("SendKeyDownDelay", Default)
Opt("SendCapslockMode", 1)
Opt("MustDeclareVars", 1)
Opt("TrayIconDebug", 1)
; Set the Escape hotkey to terminate the script.
HotKeySet("{ESC}", "_Terminate")
Global $hWnd
;Create an endless loop, 1 will always be 1 therefore True.
While 1
$hWnd = WinWait("[CLASS:#32770]", "", 60)
If WinExists($hWnd) Then
If Not WinActive($hWnd, "") Then
WinActivate($hWnd)
WinWaitActive($hWnd, "", 5)
;WinSetState($hWnd, "", @SW_MAXIMIZE)
Sleep(500)
EndIf
If WinActive($hWnd, "") Then
Send("{ENTER}")
Sleep(3000)
EndIf
EndIf
WEnd
Func _Terminate()
Exit
EndFunc ;==>_Terminate
There's no sense in using VBA for trying to open these files,
Code: Select all
#include <File.au3>
#include <WinAPIFiles.au3>
;Required 7-zip
Global $Path7z = "C:\Program Files\7-Zip"
;Global $Path7z = @ProgramFilesDir & "\7-Zip"
If Not FileExists($Path7z & "\7z.exe") Then
MsgBox(16, "", "7z.exe not found in path " & $Path7z)
Exit
EndIf
#===== CONFIG =====
Global $iPID, $sOutput = ""
Global $aFileList, $iRecycle
Global $sFolder = @ScriptDir & "\TEST\"
Global $sTempDir = @ScriptDir & "\TempDir"
If FileExists($sTempDir) Then DirRemove($sTempDir, $DIR_REMOVE)
#===== LOOP EXCEL FILES =====
;Look for excel files in selected directory and subdirectories
$aFileList = _FileListToArray($sFolder, "*.xls", $FLTA_FILES, True)
;Global $aFileList = _FileListToArrayRec($sFolder, "*.xls*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
If Not @error Then
For $i = 1 To $aFileList[0]
;use x command to keep the folder stucture, -aoa Overwrite All existing files without prompt, use -r to unzip the subfolders from the zip file
$iPID = Run('"' & $Path7z & '\7z.exe" x -aoa -r -y "' & $aFileList[$i] & '" -o"' & $sTempDir & '"', $Path7z, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($iPID)
$sOutput = StdoutRead($iPID)
;ConsoleWrite($sOutput)
If StringInStr($sOutput, "Can't open as archive", $STR_NOCASESENSEBASIC) > 0 Then
While _WinAPI_FileInUse($aFileList[$i])
Sleep(1000)
Wend
$iRecycle = FileRecycle($aFileList[$i])
If $iRecycle Then
ConsoleWrite("Deleted: " & $aFileList[$i] & @CRLF)
Else
ConsoleWrite("Error deleting: " & $aFileList[$i] & @CRLF)
EndIf
EndIf
DirRemove($sTempDir, $DIR_REMOVE)
Next
Else
MsgBox(16, "Error", "No excel files were found in the folder", 3)
EndIf
snb,
IIRC, there might still be WRITE CACHE used on storage, though I might be dating myself even bringing this up.