starlitsky Posted July 23, 2018 Posted July 23, 2018 Now I try to write the script to test the file. When I open the Microsoft Word use the function ShellExecute() although the file is opened, Word just shows the error message that file has been destroyed. But I try to open the file by myself, the file was being opened successfully, without any error. have any solution for this problem? Thanks!
Danp2 Posted July 23, 2018 Posted July 23, 2018 Show your code if you want some meaningful feedback. My guess would be that Word can't find the document due to you not supplying the correct path. Latest Webdriver UDF Release Webdriver Wiki FAQs
FrancescoDiMuro Posted July 23, 2018 Posted July 23, 2018 Why don't you use Word UDF? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
starlitsky Posted July 23, 2018 Author Posted July 23, 2018 7 minutes ago, Danp2 said: Show your code if you want some meaningful feedback. My guess would be that Word can't find the document due to you not supplying the correct path. OK, here is my code. The file was open successfully a few hours ago but suddenly can't open it. I think if my path was incorrect may even can't open the file. test.au3
starlitsky Posted July 23, 2018 Author Posted July 23, 2018 9 minutes ago, FrancescoDiMuro said: Why don't you use Word UDF? Thank for your reply, I haven't known it before!
starlitsky Posted July 23, 2018 Author Posted July 23, 2018 5 minutes ago, starlitsky said: OK, here is my code. The file was open successfully a few hours ago but suddenly can't open it. I think if my path was incorrect may even can't open the file. test.au3 How can I append my code rather than drag files?
FrancescoDiMuro Posted July 23, 2018 Posted July 23, 2018 @starlitsky Use the Code tag ( <> ) here above Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
starlitsky Posted July 23, 2018 Author Posted July 23, 2018 Just now, FrancescoDiMuro said: @starlitsky Use the Code tag ( <> ) here above <> Dim $FIlter = "D:\TestFloder" Func ScanFolder(const $Path) Local $search = FileFindFirstFile($Path & "\*.*") Local $FullPath If $search = -1 Then Return Local $first = 1 If $first = 1 Then FileWriteLine($openFile, "=====================") EndIf While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop ;break Local $test $FullPath = $Path & "\" & $file If Not StringInStr(FileGetAttrib($FullPath), "D") Then FileWrite($openFile, $file) Local $testOpen = FileOpen($FullPath, $FO_READ) ;just read the file If $testOpen = -1 Then FileWriteLine($openFile, " -> Error!") Else $PID = ShellExecute($FullPath) If $PID = -1 Then $ErrorCount += 1 FileWriteLine($openFile, " -> Error! : with return" & $PID) EndIf Else ;...another things I try, such as print, save the file EndIf FileClose($FullPath) FileWrite($openFile, $file & " close complete!" & @CRLF) Else FileWriteLine($openFile, $file) EndIf If IsFolder($FullPath) = 1 Then ScanFolder($FullPath); if still have folder then sreach it recursively $FolderCount += 1 Else $FileCount += 1 EndIf WEnd FileWrite($openFile, @CRLF) FileWrite($openFile, "=====================" & @CRLF) FileClose($search) EndFunc
FrancescoDiMuro Posted July 23, 2018 Posted July 23, 2018 This one: Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
starlitsky Posted July 23, 2018 Author Posted July 23, 2018 1 minute ago, FrancescoDiMuro said: This one: expandcollapse popupDim $FIlter = "D:\TestFloder" Func ScanFolder(const $Path) Local $search = FileFindFirstFile($Path & "\*.*") Local $FullPath If $search = -1 Then Return Local $first = 1 If $first = 1 Then FileWriteLine($openFile, "=====================") EndIf While 1 Local $file = FileFindNextFile($search) If @error Then ExitLoop ;break Local $test $FullPath = $Path & "\" & $file If Not StringInStr(FileGetAttrib($FullPath), "D") Then FileWrite($openFile, $file) Local $testOpen = FileOpen($FullPath, $FO_READ) ;just read the file If $testOpen = -1 Then FileWriteLine($openFile, " -> Error!") Else $PID = ShellExecute($FullPath) If $PID = -1 Then $ErrorCount += 1 FileWriteLine($openFile, " -> Error! : with return" & $PID) EndIf Else ;...another things I try, such as print, save the file EndIf FileClose($FullPath) FileWrite($openFile, $file & " close complete!" & @CRLF) Else FileWriteLine($openFile, $file) EndIf If IsFolder($FullPath) = 1 Then ScanFolder($FullPath); if still have folder then sreach it recursively $FolderCount += 1 Else $FileCount += 1 EndIf WEnd FileWrite($openFile, @CRLF) FileWrite($openFile, "=====================" & @CRLF) FileClose($search) EndFunc OK, I see. 😂
starlitsky Posted July 23, 2018 Author Posted July 23, 2018 6 minutes ago, mikell said: You might try _FileListToArrayRec I use shellExecute() because I need the GUI to control some situation, I just check If the encrypted file without the permissions can modify(such as paste, copy, print, capture ...etc.) the file.
starlitsky Posted July 23, 2018 Author Posted July 23, 2018 3 minutes ago, starlitsky said: I use shellExecute() because I need the GUI to control some situation, I just check If the encrypted file without the permissions can modify(such as paste, copy, print, capture ...etc.) the file. I just use the same code to run the test, but it works in morning, but now (p.m. 9: 05) can't work, and I don't why.
starlitsky Posted July 24, 2018 Author Posted July 24, 2018 I finally find my problem, just because I use #RequireAdmin to open the file. When the permission been changed, the file will skip my check. Now it works normally! Thanks, everyone!🙂
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now