Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 使用msoConnectorType创建虚线_Excel_Vba - Fatal编程技术网

Excel 使用msoConnectorType创建虚线

Excel 使用msoConnectorType创建虚线,excel,vba,Excel,Vba,我使用的excel宏当前在两个对象之间创建一条实线。我正在使用MsoConnectorStraight()。 如何创建虚线?microsoft文档中未对此进行说明 现在我是这样做的: Set sheetGRAPHE = Sheets("GRAPHE") sheetGRAPHE.Select sheetGRAPHE.Cells.Select sheetGRAPHE.Shapes.AddConnector(msoConnectorStraight, 100, 100, 100,

我使用的excel宏当前在两个对象之间创建一条实线。我正在使用MsoConnectorStraight()。 如何创建虚线?microsoft文档中未对此进行说明

现在我是这样做的:

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

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

sheetGRAPHE.Shapes(ConnectID).Line.DashStyle = msoLineSysDot
但是,您的代码可以按如下方式重新编写

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