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?
.Publish是一个sub,而不是一个函数,因此你需要取消True周围的括号。
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.