Modify Chart in Word with actxserver
이전 댓글 표시
Hello everyone, I'm working on a word template file including chart that have been included from Excel. I'm willing to modify those charts. For now I'm able to find the corresponding chart using the caption. But whenever I modify the chart, it only show 1 point in (0,0) instead of the curve that was shown before.
I would appreciate any help on this !
Thanks in advance
WordApplication=actxserver('Word.Application')
Documents = WordApplication.Documents;
Documents.Open(fullSavefile);
Doc = Documents.Item(Documents.Count);
update_word_chart_by_caption(Doc, 'Caption Title',X,Y);
function update_word_chart_by_caption(Doc, captionText, xValues, yValues, warnings)
chartObj = find_chart_by_caption(Doc, captionText);
Chart = chartObj.Chart;
xValues = double(xValues(:))';
yValues = double(yValues(:))';
Series = Chart.SeriesCollection.Item(1);
Series.XValues = xValues;
Series.Values = yValues;
Chart.Refresh;
end
function chartObj = find_chart_by_caption(Doc, captionText)
chartObj = [];
Text_Margin_Search = 50; %Search in the following 50 characters
for i = 1:Doc.InlineShapes.Count
Item = Doc.InlineShapes.Item(i);
if Item.HasChart
afterStart = Item.Range.End;
afterEnd = min(Item.Range.End + Text_Margin_Search, Doc.Content.End);
txtAfter = char(Doc.Range(afterStart, afterEnd).Text);
aroundText = normalize_text(txtAfter);
if contains(aroundText, target)
chartObj = Item;
return;
end
end
end
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!