jacky998877 Posted February 21, 2023 Posted February 21, 2023 (edited) SOLVED Edited February 21, 2023 by jacky998877
ioa747 Posted February 21, 2023 Posted February 21, 2023 have you try the MouseClickDrag() ? for Excel It has another safer way Local $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel.WorkBooks.Add ; Add a new workbook Local $ColWidth = $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth Sleep(1000) ; Display the results $oExcel.ActiveWorkBook.ActiveSheet.Cells(2, 1).Value = "ColWidth" $oExcel.ActiveWorkBook.ActiveSheet.Cells(2, 2).Value = $ColWidth Sleep(1000) ; Display the results $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth = $ColWidth * 3 $ColWidth = $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth $oExcel.ActiveWorkBook.ActiveSheet.Cells(3, 1).Value = "ColWidth" $oExcel.ActiveWorkBook.ActiveSheet.Cells(3, 2).Value = $ColWidth ;~ $oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook ;~ $oExcel.Quit ; Quit Excel spudw2k 1 I know that I know nothing
jacky998877 Posted February 21, 2023 Author Posted February 21, 2023 33 minutes ago, ioa747 said: have you try the MouseClickDrag() ? for Excel It has another safer way Local $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel.WorkBooks.Add ; Add a new workbook Local $ColWidth = $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth Sleep(1000) ; Display the results $oExcel.ActiveWorkBook.ActiveSheet.Cells(2, 1).Value = "ColWidth" $oExcel.ActiveWorkBook.ActiveSheet.Cells(2, 2).Value = $ColWidth Sleep(1000) ; Display the results $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth = $ColWidth * 3 $ColWidth = $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth $oExcel.ActiveWorkBook.ActiveSheet.Cells(3, 1).Value = "ColWidth" $oExcel.ActiveWorkBook.ActiveSheet.Cells(3, 2).Value = $ColWidth ;~ $oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook ;~ $oExcel.Quit ; Quit Excel this seems nice , thx
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