Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.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 从集合列表中自动创建并命名对象_Excel_Shapes_Vba - Fatal编程技术网

Excel 从集合列表中自动创建并命名对象

Excel 从集合列表中自动创建并命名对象,excel,shapes,vba,Excel,Shapes,Vba,我目前正在尝试从引用列表中自动命名对象,而不仅仅是在脚本中声明对象文本 如何让脚本引用一个名为processsteps的单独工作表,其中文本值位于单元格C7中,而不是作为step1在脚本中输入语句 ActiveSheet.Shapes.AddShape(msoShapeRectangle, 50, 50, 100, 50).Select Selection.Formula = "" Selection.ShapeRange.ShapeStyle = msoShapeStylePreset40 S

我目前正在尝试从引用列表中自动命名对象,而不仅仅是在脚本中声明对象文本

如何让脚本引用一个名为
processsteps
的单独工作表,其中文本值位于单元格
C7
中,而不是作为
step1
在脚本中输入语句

ActiveSheet.Shapes.AddShape(msoShapeRectangle, 50, 50, 100, 50).Select
Selection.Formula = ""
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset40
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Step1"

Peter已经提到了如何从另一个单元格中提取值。把这个提前一点

请避免使用
。选择/。激活

这就是你想要的吗

Sub Sample()
    Dim shp As Shape

    Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 50, 50, 100, 50)

    With shp.OLEFormat.Object
        .Formula = ""

        .ShapeRange.ShapeStyle = msoShapeStylePreset40

        .ShapeRange(1).TextFrame2.TextRange.Characters.Text = _
        ThisWorkbook.Sheets("Process Steps").Range("C7").Value
    End With
End Sub

请尝试
Selection.shaperage(1).TextFrame2.TextRange.Characters.Text=Sheets(“您的工作表名称”).Range(“C7”).Value