gpt4 book ai didi

excel - UiPath - VB Net - Excel - 解锁特定列

转载 作者:行者123 更新时间:2023-12-04 20:22:29 28 4
gpt4 key购买 nike

我正在尝试通过使用调用代码来解锁特定的列范围(列 I 和 J),并且我还在同一 block 中运行其他功能,例如隐藏特定列等。
我可以使用“excelWS.Columns.Locked = False”解锁所有列
但是每当我尝试指定特定范围时,我都会遇到以下异常

Invoke Code - Format Excel Worksheet: Exception has been thrown by the target of an invocation


这就是我的调用代码的设置方式:
Dim excelWB As Microsoft.Office.Interop.Excel.Workbook
excelApp = New Microsoft.Office.Interop.Excel.ApplicationClass
excelWB = excelApp.Workbooks.Open(excelFilePath)
excelWS = CType(excelWB.Worksheets(excelSheet), Microsoft.Office.Interop.Excel.Worksheet)
'Hide the Column'
excelWS.Range("M:M").EntireColumn.Hidden = True
'Set Bottom Margin to 1.1'
excelWS.PageSetup.BottomMargin = excelApp.InchesToPoints(0.433070866141732)
'Fit to One Page Width'
excelWS.PageSetup.Zoom = False
excelWS.PageSetup.FitToPagesWide = 1
'Print Tile Rows'
excelWS.PageSetup.PrintTitleRows = "$1:$12"
'Header Page 1'
excelWS.PageSetup.CenterFooter = "Page &P"
'Unlock Columns'
'excelWS.Columns.Locked = False'
excelWS.Range("I:J").EntireColumn.Locked = False
excelWB.Save
excelWB.Close
excelApp.Quit
问题行如下:
excelWS.Range("I:J").EntireColumn.Locked = False
有什么建议吗?
谢谢

最佳答案

所以更新这个;原来在整个列中有几个合并的单元格,所以一旦这些被删除,它就会重新开始工作。

关于excel - UiPath - VB Net - Excel - 解锁特定列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69176283/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com