如何使用VBA宏自动在Excel中发布HTML图表? [英] How to automatically publish a HTML Chart in Excel using a VBA Macro?

查看:258
本文介绍了如何使用VBA宏自动在Excel中发布HTML图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VBA代码每分钟自动发布Excel图表。

I am trying to publish an Excel Chart automatically every minute using a VBA code.

Sub Auto_Open()
ActiveWorkbook.PublishObjects.Add(xlSourceChart, _
 "C:\Users\file\graph.html" _
 , "Chart1", "", xlHtmlStatic, "DevXSample_16365", _
 "Graph1").Publish (True)
Application.OnTime Now + TimeValue("00:01:00"), _
 "Auto_Open"
End Sub

我在网站上抓住了这个代码,但是当我运行它时,Excel会显示此错误消息:应用程序定义或对象定义的错误。
有人知道发生了什么吗?

I've grab this code in a website but when I run it Excel displays this error message: "Application-defined or object-defined error". Does anybody know what is happening?

推荐答案

我不知道没有看到你的电子表格,但你会得到应用程序定义或对象定义的错误如果Chart1是工作表。如果您的来源是 xlSourceChart ,则Chart1必须是图表类型(通过单击选项卡并选择插入/图表创建),而不是工作表类型。

I'm not sure without seeing your spreadsheet, but you will get "Application-defined or object-defined error" if "Chart1" is a worksheet. If your source is xlSourceChart, then Chart1 must be a chart type (created by clicking on a tab and choosing Insert/Chart) not a worksheet type.

这篇关于如何使用VBA宏自动在Excel中发布HTML图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆