首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用msoConnectorType创建一条虚线

使用msoConnectorType创建一条虚线
EN

Stack Overflow用户
提问于 2020-10-07 19:03:47
回答 1查看 59关注 0票数 0

我正在使用一个excel宏,它当前在两个对象之间创建一条实线。我正在使用MsoConnectorStraight (https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.core.msoconnectortype?view=office-pia)。如何创建虚线?microsoft文档中没有说明这一点。

现在我是这样做的:

代码语言:javascript
复制
Set sheetGRAPHE = Sheets("GRAPHE")
sheetGRAPHE.Select
sheetGRAPHE.Cells.Select
sheetGRAPHE.Shapes.AddConnector(msoConnectorStraight, 100, 100, 100, 100).Name = ConnectID //Produces a straight line
sheetGRAPHE.Shapes(ConnectID).Line.ForeColor.RGB = RGB(250, 0, 0)
sheetGRAPHE.Shapes(ConnectID).Line.Weight = 1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-07 20:08:28

可以将LineFormat对象的DashStyle属性设置为msoLineSysDot。

代码语言:javascript
复制
sheetGRAPHE.Shapes(ConnectID).Line.DashStyle = msoLineSysDot

但是,您的代码可以重写如下...

代码语言:javascript
复制
Dim sheetGRAPHE As Worksheet
Set sheetGRAPHE = Sheets("GRAPHE")

Dim shp As Shape
Set shp = sheetGRAPHE.Shapes.AddConnector(msoConnectorStraight, 100, 100, 100, 100)

With shp
    .Name = ConnectID
    With .Line
        .DashStyle = msoLineSysDot
        .ForeColor.RGB = RGB(250, 0, 0)
        .Weight = 1
    End With
End With
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64242721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档