Jump to content

graybags

Active Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by graybags

  1. That was one of the first things I tried, but it didn't work, just gave me a -1 error.
  2. Hi, I'm currently using this script to generate an array called $usernames which just contains the members of an AD group: #include <Array.au3> $objGroup = ObjGet("LDAP://cn=just_a_group,ou=groups,dc=here,dc=com") $objGroup.GetInfo $arrMemberOf = $objGroup.GetEx("member") Local $usernames[UBound($arrMemberOf)] For $i = 0 To UBound($arrMemberOf) - 1 $usernames[$i] = $arrMemberOf[$i] Next It works fine, but I never wrote it and I'd normally use the AD udf to do it. But I've tried and failed! How would I do the above with the AD udf? Thanks, Graybags
  3. I think I've sorted the column name array. Created an array with: Local $ColumnInTab[0] Then: _ArrayAdd ( $ColumnInTab, _Excel_ColumnToLetter($iCol + 1)) and for the single column: _ArrayAdd ( $ColumnInTab, "A") Thanks again for your help, what would I do without this forum!
  4. That works for a sheet with just one column, great. Just need to sort the column name array now
  5. Yes, the correct data is being read, even with a sheet with just one column.
  6. Oooh, just a couple of more things, sorry. I can't seem to get the script to work if the spreadsheet has just one column, it doesn't write "A" as I'd expect. Also, how would I write the result to an array? Thanks!
  7. That's it! Thanks so much, I really appreciate the help.
  8. Nothing huge, but it's down to the user to choose the sheet, I'll have no control of that, but realistically no more than 200 rows and maybe columns A-M, so 13 columns. So around 2,500 cells.
  9. Ah yes, that works thanks. I've run it for a workbook I have and I'm selecting various sheets. For one it's still listing a huge list of rows (1871) for a worksheet with only 38 used ones. I've scrolled down to that row and indeed that row and beyond have cells with borders, so someone has obviously done something odd with spreadsheet in the past, and I don't have any control of that. If I create a blank sheet and copy and paste the "real" data the console tells me tells me: $A1:$A38 $B1:$B38 $C1:$C38 $D1:$D38 $E1:$E38 $F1:$F38 $G1:$G38 $H1:$H38 $I1:$I38 $J1:$J38 ...which is correct. But I can't correct every sheet like I did as the user chooses the sheets. It looks like I might have to bite the bullet and just ask the user to input the tab. Thanks again for your help, I thought we were getting close. Somebody needs to write a UsedRangeWithDataActuallyInACell function
  10. #include <Excel.au3> #include <MsgBoxConstants.au3> ; Create application object Local $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Open an existing workbook and return its object identifier. Local $sWorkbook = @ScriptDir & "\test.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Workbook '" & $sWorkbook & "' has been opened successfully." & @CRLF & @CRLF & "Creation Date: " & $oWorkbook.BuiltinDocumentProperties("Creation Date").Value) ; Read data from a single cell on the active sheet of the specified workbook Local $sResult = _Excel_RangeRead($oWorkbook, Default, "A1") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Data successfully read." & @CRLF & "Value of cell A1: " & $sResult) $oWorksheet = $oWorkbook.Sheets(2).Activate For $oColumn In $oWorksheet.UsedRange.Columns ConsoleWrite($oColumn.Address(False, True) & @CRLF) Next ok, just using that as a really simple example to test things, i'm getting an error: Variable must be of type "Object".: For $oColumn In $oWorksheet.UsedRange.Columns For $oColumn In $oWorksheet^ ERROR what have I done wrong???
  11. Yeah, i figured Excel would remember a cell that had been touched and deleted and label that as used. Damn. I was hoping there was a way to see if the column something in, kind of a CurrentlyUsedRange object The headers on each worksheet are different, so I can't do that. Oh well, thanks for reading, I'll guess I have to just get the user to manually imput their column like I am.
  12. That's what I've done in the past with a previous script, I was just hoping there was a way they could actually see their options and just tick one.
  13. Hi, This has really stumped me! My script so far allows a user to open a workbook and then reads in the names of the worksheets into an array. But now I need to get the user to choose which column in their chosen worksheet has the data they are interested in, by bringing up a list of the used columns on the worksheet. So they browse to a workbook, then they select the worksheet from a list, and then I'd like another list to appear showing "A B C D..." on so on, for however many columns that worksheet uses. Is that possible? Thanks!
  14. Oh dear, that must have been a typo! 🥴
  15. Excellent, thanks for the replies above. Both of those worked perfectly, but I could only mark one as the solution.
  16. Thanks for the reply. No, that still doesn't close the gui as soon as the "X" is clicked.
  17. Hi, I've got a really simple script that just shows the time of a remote computer. But, due to the way it's written, I can't close the gui immediately. Is there a way around this? Thanks, Graybags #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> $Computer = "xxx" Local $timestamp $GUI = GUICreate( $computer & " time", 150, 80, "", "", BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD)) WinSetOnTop ($GUI, "", 1) GUICtrlSetFont ( -1, "10", "800", "", "Consolas" ) GUICtrlCreateLabel( $timestamp, 20, 10, 120, 350) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch $aTime = TimeCalc($Computer) WEnd Func TimeCalc($Computer) $Cmd_out = _GetDOSOutput("net time \\" & $Computer) If $Cmd_out <> "" Then $Cmd_array = StringSplit($Cmd_out, "is ", 1) $Cmd_array2 = StringSplit($Cmd_array[2], @CRLF, 1) $Cmd_array3 = StringSplit($Cmd_array2[1], " ", 1) $timestamp = $cmd_array3[2] GUICtrlSetFont ( -1, "18", "800", "", "Consolas" ) GUICtrlSetData ( -1, $timestamp ) Sleep(60000) EndIf EndFunc Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf WEnd Return $sOutput EndFunc
  18. Hi, This looks like a really handy UDF. We've just migrated all our printers from one server to another. Is there a way I could use the UDF to create a script that could be run on a user's PC, that would delete all the printer connections on the old server? i.e. _RemovePrinter \\ser000001\* Thanks, Graybags
  19. Excellent! That worked! I cannot thank you all enough for the help. Seems so easy now I look at it. Thanks again.
  20. I had about 4 test PC's I was running these scripts on. I just went to a meeting and came back to find that someone is putting them out on the shopfloor! I'm going to have to restage another PC from scratch and try that script, but it looks good and I'm excited, thanks
  21. Ooh... That actually seems to work. So I can just call that from the Autoit script maybe?
  22. Tried that, and although I was excited... It never worked. The folder copies across ok but it still doesn't seem to want to run the install. Damn! The admin credentials I don't think is an issue, as I am logged onto the PC as an admin. Oh well, thanks everyone for the suggestions.
  23. I'm not sure... I *think* I did, but then I didn't really understand what "working directory" meant anyway. Could and would that make a difference?
×
×
  • Create New...