I am trying to get some graphs into a form. After much searching, I have decided to use Excel to make the graphs.
What I’m planning on doing is putting the data from the form into a excel worksheet, making the graph needed, saving it into the users temp file, then importing it into a rich text feild.
I’m running into problems with the saving part. When I use SaveCopyAs I get an error, and when I use Save I’m prompted to enter the path.
How can I save the file to the path I choose without getting the save prompt?
Thanks.
Subject: Excel Graphing
Hi,
I did it once through exporting the graph from Excel as a GIF-picture and then “importing” this picture into a RTF-Field.
Here is some code: (its ripped out so it will not work, but it might help)
FilePath = “c:\temp\PreparedExcelFile.xls”
Set Excel = CreateObject("Excel.Application")
Excel.Application.Visible = True
' open the excel file
Set Workbook = Excel.Workbooks.Open(FilePath)
' now fill all teh cells with the data
Excel.Range("A1").Value = 1
Excel.Range("A2").Value = 2
'....
' export the graphs as GIF-pictures to the temp-dir
For i = 1 To Workbook.Worksheets("List1").ChartObjects.Count
Call Workbook.Worksheets("Graphs").ChartObjects(i).Chart.Export(Environ(TEMP) + "\" + Cstr(i) + ".gif", "GIF")
Next
' open the document in EDIT-mode
Set uidoc = Workspace.EditDocument(True,Doc)
Call uidoc.GotoField("Charts") ' goto a RTF-Field
Call uidoc.Import("GIF Image", Environ(TEMP) + "\1.gif") ' import the picture to the RTF-Field
Kill Environ(TEMP) + "\1.gif" ' remove the picture-file
' save and close the document
Call uidoc.Save
Call uidoc.Close(True)
'close Excel
Call Workbook.Close(False)
Call Excel.Quit()
Hope this helps.
Bye
Hynek
Subject: RE: Excel Graphing
Thank you so much Hynek. It workes great!