用LISP给EXCEL单元格加外框
麻烦大神们指点一下
用LISP给EXCEL单元格加外框出错,谢谢
(setq excel (vlax-get-object "excel.application"))
(setq cells (Vlax-Get excel 'Cells))
(setq kkk_dyg (vlax-variant-value
(vlax-get-property cells "item" 3 3 )
)
)
(vlax-for a (vlax-get-property kkk_dyg "Borders")
(vlax-put-property
kkk_dyg
a
"LineStyle"
"xlContinuous"
)
)
参数类型错误: (or stringp symbolp): #<VLA-OBJECT Border 03e047ac>
本帖最后由 yshf 于 2018-2-4 22:35 编辑
;(vlax-get-property cells "item" 3 3 ) ;是得到单元格的值,并非单元格对象本身
;Excle对象的层次要分清:application->WorkBooKs->WorkBooK->WorkSheets->WorkSheet->Range、Cells
; ActiveCell当前活动单元格
; ActiveSheet 当前活动工作表
; ActiveWorkbook 当前活动工作簿
(if (setq ExcelApp (vlax-get-object "excel.application"))
(progn
(setq Sheet (vlax-get-propertyExcelApp "ActiveSheet"))
(setq Range (Vlax-Get-property Sheet "Range" "C3:C3"))
(setq Borders (Vlax-Get-property Range "Borders"))
(setq i 7)
(repeat 4
(vlax-put-property
(vlax-get-property Borders "item" i)
"LineStyle"
1
)
(setq i (1+ i))
)
)
)
是不是应该将:
(vlax-put-property
kkk_dyg
a
"LineStyle"
"xlContinuous"
)
改为:
(vlax-put-property
kkk_dyg
a
"LineStyle"
1 ;;Const xlContinuous = 1
)
yshf 发表于 2018-2-3 23:18
是不是应该将:
(vlax-put-property
kkk_dyg
还是不行,提示出错参数类型错误: (or stringp symbolp): #<VLA-OBJECT Border 0ad8de04> yshf 发表于 2018-2-4 22:33
;(vlax-get-property cells "item" 3 3 ) ;是得到单元格的值,并非单元格对象本身
;Excle对象的层 ...
非常感谢,可以了:handshake yshf 发表于 2018-2-4 22:33
;(vlax-get-property cells "item" 3 3 ) ;是得到单元格的值,并非单元格对象本身
;Excle对象的层 ...
学习了,解释的很清楚,总算弄明白一点了,感谢感谢 感谢论坛,我当初也是不知道怎么加外框等等诸如此类的问题,虽然 没提问,也是从本站搜到了好多代码才解惑。
页:
[1]