- Dim EV As SpreadsheetGear.Windows.Co**ols.WorkbookView,AW As SpreadsheetGear.IWorkbook,Range As SpreadsheetGear.IRange
- Public Sub Workbook_Open(OldRoot As Object,NewRoot As Object,Excel As SpreadsheetGear.Windows.Co**ols.WorkbookView)
- EV = Excel
- Excel.GetLock()
- AW = Excel.ActiveWorkbook
- Range = AW.ActiveWorksheet.Range
- Excel.ReleaseLock()
- AddHandler Excel.RangeSelectionChanging, Sub(s2 As Object, e2 As SpreadsheetGear.Windows.Co**ols.RangeSelectionChangingEventArgs)
- If e2.RangeSelection.Locked = True Then
- e2.Cancel = True
- End If
- End Sub
复制代码 选择只读单元格后会返回原选择的单元格。
新版VBA的使用代码如上,在默认的语句后加上
- AddHandler Excel.RangeSelectionChanging, Sub(s2 As Object, e2 As SpreadsheetGear.Windows.Co**ols.RangeSelectionChangingEventArgs)
- If e2.RangeSelection.Locked = True Then
- e2.Cancel = True
- End If
- End Sub
复制代码 即可
7.0以下版本使用VBA编辑器生成DLL,代码使用可参考VBA控制不能选择非编辑单元格
|
|
hong90342