|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 justzzq 于 2011-8-19 14:01 编辑
学习VBA,用宏画了的一些曲线,颜色和线型都是默认的。请教各位高手,怎样才能在宏中用代码指定线型和颜色?
还有,代码中指定了ActivePresentation.Slides(1),怎样才能将曲线画在当前幻灯片中?
宏代码如下:
Sub DrawSin()
Const PI As Single = 3.1415
Const Period As Single = 200
Dim i As Single, n As Single, m As Single
Dim sinArray() As Single
n = InputBox("请输入周期数", "周期", 2, 300, 200)
m = InputBox("请输入起始角度", "起始角度", 0, 300, 200)
x = Int(n * Period / 3) * 3 + 1 '必须的,点数为 3n+1
ReDim sinArray(1 To x, 1 To 2) As Single
For i = 1 To x
sinArray(i, 1) = 100 + i
sinArray(i, 2) = 200 - 50 * Sin(2 * PI * i / Period + m * PI / 180)
Next
'添加贝塞尔曲线
Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddCurve SafeArrayOfPoints:=sinArray
End Sub
|
|