PhilBall Posted March 23, 2012 Share Posted March 23, 2012 Hi there I have created a script that will show the file open dialog with a filter on the first 3 digits of the filename. I can get it to work to open one file, but when it comes to opening multiple files, I have created a further script as per below, but cannot seem to get it to work. I'd appreciate a fresh pair of knowledgable eyes on this. thanks, very much, Phil #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=C:\Users\phil.PAYCHECK\Desktop\PDF.ICO #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <Array.au3> $SC = InputBox("Open a PDF","Type the SC of the PDFs you want to see") $filter = "PDFs (" & $SC & "*.pdf)" $message = "Hold down Ctrl or Shift to choose multiple files." $var = FileOpenDialog($message, "S:\Shared\EXCEL\PDF\", $filter, 1 + 4 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else $var = StringReplace($var, "S:\Shared\EXCEL\PDF", "") $var = StringReplace($var, "|", ",S:\Shared\EXCEL\PDF\") $files = StringSplit($var,",") EndIf ;_ArrayDisplay($files) $end = _ArrayMaxIndex($files) $n = 1 while $n < $end $n = $n + 1 ;msgbox(4096,"",$files[$n]) ShellExecute($files[$n]) WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 23, 2012 Moderators Share Posted March 23, 2012 PhilBall,_ArrayMaxIndex does not do what you think it does - it tells you the element with the highest value, not the number of elements. For that you use UBound. But in fact StringSplit gives you the count in the [0] element so you can do this: For $n= 2 To $files[0] MsgBox(4096, "", $files[$n) ;ShellExecute($files[$n]) NextYou need to start at 2 becaus the [0][ element is the count and [1] will always be empty because you have a leading "," which you add. All clear? Please ask if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Reg2Post Posted March 23, 2012 Share Posted March 23, 2012 (edited) To add to Melba23's comments, if you are going to use a while loop, you need to add one to either the $files[0] count element or Ubound($files) with your less than operator. Example: $n = 2 While $n < $files[0] + 1 MsgBox(4096, "", $files[$n]) $n = $n + 1 WEnd Edited March 23, 2012 by Reg2Post Link to comment Share on other sites More sharing options...
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