How to automatically publish a HTML Chart in Excel using a VBA Macro?

白昼怎懂夜的黑 提交于 2019-12-08 13:52:32

问题


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

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?


回答1:


.Publish is a sub, not a function so you'll need to take away the parenthesis around the True.




回答2:


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.



来源:https://stackoverflow.com/questions/8346707/how-to-automatically-publish-a-html-chart-in-excel-using-a-vba-macro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!