Word中Table边框设置问题?

paulpeath 2012-09-27 01:48:30
在Excel可选择单元格的一个区域设置边框。
如下:sh.OlePropertyGet("Range","A1:C10").OlePropertyGet("Borders").OlePropertySet("linestyle",2);
//给指定区域的所有单元格加上边框,最后的数字:1=细实线框,2=短距虚线框,3=长距虚线框,4=点划线,5=双点划线,6=粗点划线
对于word中的Table,可否对于一个3行4列的表,整体设置其边框呀?
...全文
388 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
妖哥,如果我想让某个单元格的上下左右边框分别隐藏怎么办 上面代码没看太懂
ccrun.com 2012-09-27
  • 打赏
  • 举报
回复
// 左侧的外边框设成 wdLineStyleDashLargeGap
vTable.OlePropertyGet("Borders").OleFunction("Item", -2).OlePropertySet("LineStyle", 4);
// 右侧的外边框设成 wdLineStyleDouble
vTable.OlePropertyGet("Borders").OleFunction("Item", -4).OlePropertySet("LineStyle", 7);
paulpeath 2012-09-27
  • 打赏
  • 举报
回复
ccrun:
妖哥,谢谢!代码很好。如何设置左、右边框呀?
hyz_cs 2012-09-27
  • 打赏
  • 举报
回复
准备放假了吧,哈哈
ccrun.com 2012-09-27
  • 打赏
  • 举报
回复
这两天人气很差啊,人都哪里去了。
ccrun.com 2012-09-27
  • 打赏
  • 举报
回复
OLE专业户来也!!!

Variant vWordApp;
try
{
vWordApp = Variant::CreateObject("Word.Application");
}
catch(...)
{
MessageBox(Handle, "启动Word出错!",
Application->Title.c_str(), MB_OK | MB_ICONERROR);

return;
}

vWordApp.OlePropertySet("Visible", true);

Variant vDoc = vWordApp.OlePropertyGet("Documents").OleFunction("Add");

vWordApp.OlePropertyGet("ActiveDocument")
.OlePropertyGet("Tables").OleProcedure("Add",
vWordApp.OlePropertyGet("Selection").OlePropertyGet("Range"),
3, // NumRows
4, // NumColumns
1, // DefaultTableBehavior:=wdWord9TableBehavior
0); // AutoFitBehavior:=wdAutoFitFixed
Variant vTable = vWordApp.OlePropertyGet("ActiveDocument").
OleFunction("Range").OlePropertyGet("Tables").OleFunction("Item", 1);

vTable.OlePropertyGet("Borders").OlePropertySet("InsideLineStyle", 5); // wdLineStyleDashDot
vTable.OlePropertyGet("Borders").OlePropertySet("OutsideLineStyle", 20); // wdLineStyleDashDotStroked

...

703

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder ActiveX/COM/DCOM
社区管理员
  • ActiveX/COM/DCOM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧