显示“活动” Excel Userform中的图表数据

编程入门 行业动态 更新时间:2024-10-11 11:18:39
本文介绍了显示“活动” Excel Userform中的图表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以,我一直在研究在用户窗体中显示图表的模式。一般的共识似乎是,你必须将图表保存为.GIF文件,然后将其在用户窗体中作为图像上传,但是,这将意味着任何使用userform的人必须将文件保存为图像为了查看信息(我不相信任何我的同事会花时间学习如何做到这一点,他们只是想快速图表视图)。

So, I have been researching the modes of displaying charts in a userform. The general consensus seems to be that you have to save the chart as a .GIF file and then upload this within the userform as an image, however, this would then mean that anyone using the userform would have to have the file saved as an image in order to view the information (and I do not believe that any of my associates will take the time to learn how to do this, they just want a quick chart-view).

有没有解决方法来显示用户表单内的图表(不断更新的数据)?我尝试了多种途径,没有找到任何东西...此外,我的Excel 2013似乎没有在工具箱中的Microsoft Office图表选项,这是已经改变了吗?

Is there a workaround to display the chart (which is constantly being updated by data that comes in) within a userform? I have tried multiple avenues and am not finding anything... Also, my Excel 2013 does not appear to have the Microsoft Office Charts option within the Toolbox, is this something that has been changed?

谢谢!

推荐答案

案例1:如果图表在工作表上,

Case 1: If the chart is on the worksheet, it will be easier as below:

Private Sub UserForm_Initialize() Dim Fname As String Call SaveChart Fname = ThisWorkbook.Path & "\temp1.gif" Me.Image1.Picture = LoadPicture(Fname) End Sub Private Sub SaveChart() Dim MyChart As Chart Dim Fname As String Set MyChart = Sheets("Data").ChartObjects(1).Chart Fname = ThisWorkbook.Path & "\temp1.gif" MyChart.Export Filename:=Fname, FilterName:="GIF" End Sub

$情况2:如果图表不在工作表上,您可能需要创建一个临时图表,将其保存为GIF,将其删除,最后加载图片{

Case 2: If chart is not on the worksheet, you may need to create a temporary chart, save it as GIF, delete it, and finally load the picture {

Me.Image1.Picture = LoadPicture(Fname)

}当用户初始化时。

案例1更容易编码。上面的代码仍然工作,即使我剪切和粘贴图表在以后隐藏的工作表。

Case 1 is easier to code. The above code still works even I cut and paste the chart in a later-hidden worksheet.

更多推荐

显示“活动” Excel Userform中的图表数据

本文发布于:2023-07-09 20:56:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1088185.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图表   数据   Excel   Userform

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!