| 1 | #include <Excel.au3>
|
|---|
| 2 | #include <Array.au3>
|
|---|
| 3 |
|
|---|
| 4 | func _openSourceData()
|
|---|
| 5 | $sourcefile=FileOpenDialog("Please select source file",@ScriptDir,"All (*.*)")
|
|---|
| 6 | If @error Then
|
|---|
| 7 | ; Display the error message.
|
|---|
| 8 | MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
|
|---|
| 9 | else
|
|---|
| 10 | ; Create application object
|
|---|
| 11 | Local $oAppl = _Excel_Open()
|
|---|
| 12 | If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
|
|---|
| 13 | ; *****************************************************************************
|
|---|
| 14 | ; Open an existing workbook and return its object identifier.
|
|---|
| 15 | ; *****************************************************************************
|
|---|
| 16 | Local $sWorkbook = $sourcefile
|
|---|
| 17 | $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
|
|---|
| 18 | If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
|
|---|
| 19 | $sourceArray=_Excel_RangeRead($oWorkbook)
|
|---|
| 20 | _ArrayDisplay($sourceArray)
|
|---|
| 21 | $unique=_ArrayUnique($sourceArray)
|
|---|
| 22 | _ArrayDisplay($unique)
|
|---|
| 23 | EndIf
|
|---|
| 24 | EndFunc
|
|---|
| 25 | _openSourceData()
|
|---|