Hi Hans,
How is the code you post not working for you through an asp interface?
Are you able to save this Excel workbook with the graph to disk?
If you are, then I recommend NOT going over the clipboard
(Insert/Object/From File), or replicating the result you'd get if you
went over PasteSpecial with a link, then break the link (which should
give you a graphic in the document).
Or create the graph directly in the Word document, then unlink the OLE
field code to turn it into a graphic.
Does any of these sound like a possible approach?
> I'm writing an asp application in wich I dynamically create an
> Excel-graph.
[quoted text clipped - 14 lines]
> oWordDoc.Bookmarks("product").Range.PasteSpecial Link = False, DataType
> = wdPasteBitmap, Placement = wdInLine, DisplayAsIcon = False
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
hans - 08 Feb 2006 15:31 GMT
Hi Cindy,
This could be a solution, but the problem is that I have to create
hundreds of graphs that will be dynamically altered, so I should save
the excel-file each time, insert the object in word; open excel again
to change the graph, close it again end so on.
Instead I created the following code to do the job, but unfortunately I
get an error (see below):
oExcelSht.ChartObjects("Graph 1").Activate
oExcelApp.ActiveChart.ChartArea.Select
oExcelApp.ActiveChart.ChartArea.Copy
'Create an instance of Word Application
set oWordApp = Server.CreateObject("Word.Application")
'Make wordApp visible
oWordApp.visible = true
oWordApp.DisplayAlerts = false
'New document (based on sWordTemplateFile)
set oWordDoc = oWordApp.Documents.Add(sWordTemplateFile)
'Paste chart
oWordApp.selection.paste
'Save document
oWordApp.ActiveDocument.SaveAs sWordTargetFile
'Quit Word
oWordDoc.close
oWordApp.Quit
set oWordDoc = Nothing
set oWordApp = Nothing
The error I get is:
Runtime error 4605: This method or property is not valid because the
Clipboard is empty or not valid.
Do you know why I get this error?
hans - 08 Feb 2006 17:01 GMT
Cindy,
I found what caused the error. For some reasen word was opened by a
different user as the one that opened excel. Obviously the clipboard is
empty in that case!!!
Thanks for your effort anyway!!!
Hans