Jump to content

Search the Community

Showing results for tags '2010'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hey guys, I am finishing up a script that will run a import a lof of VBA code, the .bas files, (more VBA code than can easily be ported into AutoIt. Thousands of lines...) to do some work on Excel spreadsheets. However, Excel has a security setting where it blocks macros from being run/loaded, unless both the "Enable All Macros" setting is enabled, and the "Trust access to the VBA project object model" checkbox is enabled. However, that checkbox appears to be fake. Using the AutoIt WindowInfo tool, there is no control ID for that checkbox. I have spent the last several hours trying to get this to work. Here is what I have so far, all of the control-send down/up etc are to get to the right menu options inside Excel. #include <Excel.au3> #include <FileConstants.au3> Global $oExcel, $oWorkbook, $oCurrSheet, $sMsg Global $sXLS = "C:\Users\SNIP\Downloads\test.xlsm" Global $sWorkbook = @ScriptDir & "\test.xlsm" Global $sBAS = @ScriptDir & "\Module1.bas", $sMacroName = "Main" SelectExcelFile() SelectBASFile() $oExcel = _Excel_Open() $sWorkbook = _Excel_BookOpen($oExcel, $sWorkbook); WinWaitActive("Microsoft Excel - " & $sWorkbook) ;MsgBox($MB_OK,"Open","Workbook is open") ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!f"); Sleep(50) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!t"); Sleep(50) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!f"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{TAB}"); Sleep(105) ControlSend("Microsoft Excel - " , "", "", "{ENTER}"); Sleep(105) ControlSend("Excel Options", "", "", "!t"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{UP}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{DOWN}"); Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!e") Sleep(105) ControlSend("Trust Center", "", "", "!v") ;This part is not working. It doesn't select the checkbox, even though alt+v does manually. Sleep(100) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "{ENTER}") Sleep(105) ControlSend("Microsoft Excel - " & $sWorkbook, "", "", "!{F4}") $oExcel.VBE.ActiveVBProject.VBComponents.Import($sBAS) $oExcel.Application.Run("Main") ;These two functions are just to select the files. Func SelectExcelFile() ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Select Excel File To Sort." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Excel Files (*.xlsx;*xlsm;*.xls;)|", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Display the list of selected files. $sWorkbook = $sFileOpenDialog ;Assign the file selected to the workbook file ; MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog) EndIf EndFunc ;==>Example Func SelectBASFile() ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Select BAS Macro." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "BAS Files (*.bas;)|", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Display the list of selected files. $sBAS = $sFileOpenDialog ;Assign the file selected to the workbook file ;MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog) EndIf EndFunc ;==>Example What's the best way to get the value of that imaginary checkbox, and if it isn't checked, check it? Or if it is checked, leave it alone? I tried doing a PixelSearch but that didn't work. And I can't manually enable the developer settings. This program will go to a few other users who won't know how to do that, and I can't remote in.
×
×
  • Create New...