vba 练习作业 急!!!
发布网友
发布时间:2022-05-01 15:55
我来回答
共2个回答
热心网友
时间:2022-06-19 03:01
你这还是繁体字。你先手动画出这个图形来,看看它的属性。用VBA关键是在对它属性的计算和调整追问能否给出一个例子的附件啥的或者代码。繁体字啥的别管啦。能给我一个具体的答案我就采用咯亲~
热心网友
时间:2022-06-19 03:02
Sub test()
Dim MyLeft, MyTop, MyWidth, MyHeight, CellsLeft, CellsWidth, CellsLeft2, CellsWidth2, CellsColumnStart, CellsColumnStop As Integer
Dim MyShape As Shape
Dim MyTimeStart, MyTimeStop
CellsColumnStart = Hour(Cells(3, 2)) - 4
CellsColumnStop = Hour(Cells(3, 3)) - 4
CellsLeft = Cells(7, CellsColumnStart).Left
CellsLeft2 = Cells(7, CellsColumnStop).Left
CellsWidth = Cells(7, CellsColumnStart).Width
CellsWidth2 = Cells(7, CellsColumnStop).Width
MyTimeStart = Cells(3, 2)
MyTimeStop = Cells(3, 3)
MyLeft = CellsLeft + Minute(MyTimeStart) * CellsWidth / 60
MyTop = Cells(7, 2).Top + (Cells(7, 2).Height - 20) / 2
MyWidth = CellsLeft2 - MyLeft + Minute(MyTimeStop) * Cells(7, CellsColumnStop).Width / 60
MyHeight = 20
On Error Resume Next
Shapes("test").Delete
Set MyShape = Shapes.AddShape(msoShapeRectangle, MyLeft, MyTop, MyWidth, MyHeight)
MyShape.Name = "test"
End Sub