在 PowerPoint 中分配来自 Excel 的形状属性
Assign shape properties from Excel in PowerPoint
我想分配可以在 .AddShape
命令中定义的属性(左、上、宽、高),方法是使用 Excel。
现在我已经直接在代码中分配属性了。目标是仅使用 Excel-Workbook
.
中的数据(Left、Top、Width、Height)修改属性
例如,我在 Excel 中有一个 table 具有以下数据,它仅通过编辑 Excel 中的数据来改变形状:
Length: 500
Top: 200
Width: 50
Height: 20
我当前的代码如下所示:
Sub Text_EAP()
Dim WB As Workbook, wks As Worksheet
Set WB = Workbooks.Open(FileName:="U:\Automatisierung\Auto.xlsx", ReadOnly:=True)
Set wks = WB.Worksheets("Tabelle1") '<--- Here is the table with the property data
Set sld = ActivePresentation.Slides(2)
Set shp = sld.Shapes.AddShape(51, 607, 195, 70, 15) '<--- The property data here shall be changed accordingly to the Excel-Data
shp.Name = "Konzentration"
shp.Fill.ForeColor.RGB = RGB(192, 0, 0)
shp.TextFrame.TextRange.Text = "Konzentration"
shp.TextFrame.TextRange.Characters.Font.Size = 6
shp.Line.Visible = msoFalse
'Exceldatei schliessen
WB.Close SaveChanges:=False
End Sub
我如何更改将从 Excel-Workbook
中的数据中提取 shape-properties
的代码。
感谢您的帮助!
像这样的东西会起作用:
Set shp = sld.Shapes.AddShape(wks.Range("A1"), wks.Range("A2"), 195, 70, 15)
更改其他参数。
代码:
Sub Text_EAP()
Dim WB As Workbook, wks As Worksheet
Dim ex As Object
Set ex = CreateObject("Excel.Application")
Set WB = ex.Workbooks.Open(FileName:="U:\Automatisierung\Auto.xlsx", ReadOnly:=True)
Set wks = WB.Worksheets("Tabelle1")
Set sld = ActivePresentation.Slides(1)
Set shp = sld.Shapes.AddShape(wks.Range("A1"), wks.Range("A2"), 195, 70, 15) ' Change all the values & Ranges accordingly
shp.Name = "Konzentration"
shp.Fill.ForeColor.RGB = RGB(192, 0, 0)
shp.TextFrame.TextRange.Text = "Konzentration"
shp.TextFrame.TextRange.Characters.Font.Size = 6
shp.Line.Visible = msoFalse
WB.Close SaveChanges:=False
End Sub
我想分配可以在 .AddShape
命令中定义的属性(左、上、宽、高),方法是使用 Excel。
现在我已经直接在代码中分配属性了。目标是仅使用 Excel-Workbook
.
例如,我在 Excel 中有一个 table 具有以下数据,它仅通过编辑 Excel 中的数据来改变形状:
Length: 500
Top: 200
Width: 50
Height: 20
我当前的代码如下所示:
Sub Text_EAP()
Dim WB As Workbook, wks As Worksheet
Set WB = Workbooks.Open(FileName:="U:\Automatisierung\Auto.xlsx", ReadOnly:=True)
Set wks = WB.Worksheets("Tabelle1") '<--- Here is the table with the property data
Set sld = ActivePresentation.Slides(2)
Set shp = sld.Shapes.AddShape(51, 607, 195, 70, 15) '<--- The property data here shall be changed accordingly to the Excel-Data
shp.Name = "Konzentration"
shp.Fill.ForeColor.RGB = RGB(192, 0, 0)
shp.TextFrame.TextRange.Text = "Konzentration"
shp.TextFrame.TextRange.Characters.Font.Size = 6
shp.Line.Visible = msoFalse
'Exceldatei schliessen
WB.Close SaveChanges:=False
End Sub
我如何更改将从 Excel-Workbook
中的数据中提取 shape-properties
的代码。
感谢您的帮助!
像这样的东西会起作用:
Set shp = sld.Shapes.AddShape(wks.Range("A1"), wks.Range("A2"), 195, 70, 15)
更改其他参数。
代码:
Sub Text_EAP()
Dim WB As Workbook, wks As Worksheet
Dim ex As Object
Set ex = CreateObject("Excel.Application")
Set WB = ex.Workbooks.Open(FileName:="U:\Automatisierung\Auto.xlsx", ReadOnly:=True)
Set wks = WB.Worksheets("Tabelle1")
Set sld = ActivePresentation.Slides(1)
Set shp = sld.Shapes.AddShape(wks.Range("A1"), wks.Range("A2"), 195, 70, 15) ' Change all the values & Ranges accordingly
shp.Name = "Konzentration"
shp.Fill.ForeColor.RGB = RGB(192, 0, 0)
shp.TextFrame.TextRange.Text = "Konzentration"
shp.TextFrame.TextRange.Characters.Font.Size = 6
shp.Line.Visible = msoFalse
WB.Close SaveChanges:=False
End Sub