Excel VBA 用户界面与对话框技巧
1. UserForm 技术与技巧
在一个示例中,有三张图表位于名为“Charts”的工作表中。通过“Previous”和“Next”按钮来确定显示哪张图表,图表编号存储在公共变量“ChartNum”中,所有程序都可访问该变量。以下是实现此功能的 UpdateChart 过程:
Private Sub UpdateChart()
Dim CurrentChart As Chart
Dim Fname As String
Set CurrentChart = _
Sheets("Charts").ChartObjects(ChartNum).Chart
CurrentChart.Parent.Width = 300
CurrentChart.Parent.Height = 150
' Save chart as GIF
Fname = ThisWorkbook.Path & "\temp.gif"
CurrentChart.Export FileName:=Fname, FilterName:="GIF"
' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub
此过程为保存的图表确定一个名称,然后使用 Export 方法导出 GIF 文件,最后使用 VBA 的 LoadPicture 函数指定 Ima
Excel VBA用户界面定制技巧
超级会员免费看
订阅专栏 解锁全文
11

被折叠的 条评论
为什么被折叠?



