I have an OLE object (called oleExcel) on my form that displays a chart (oleExcel.Class = Excel.Chart.5). A common dialog box (dlgSave) is also present. I use the following code to save the workbook:
Set mobjBook = oleExcel.object.Parent
dlgSave.ShowSave
mobjBook.SaveCopyAs dlgSave.filename
This works wonderfully. However, two strange things happen:
1) when I launch Excel and open the saved workbook, it is always hidden. It doesn't matter if the VB app is still running or not.
2) when I do 1) while my app is still running and the form is still open, a second hidden workbook is shown as open (e.g. "Book 1"). If I open that second workbook, the chart that appears on my VB form suddenly grows and becomes only partially visible in the OLE object.
I can live without understanding the latter point, but my clients will be really bugged if they have to unhide their workbook every time they export one.
____________________________
J'ai un objet OLE (appellé oleExcel) sur ma forme qui montre un graphe (oleExcel.Class = Excel.Chart.5). J'utilise également une fenêtre de dialogue (dlgSave). Je me sers du code suivant pour sauvegarder le workbook:
Set mobjBook = oleExcel.object.Parent
dlgSave.ShowSave
mobjBook.SaveCopyAs dlgSave.filename
Ca marche bien. Cependant, deux choses étranges se passent:
1) quand je démarre Excel et j'ouvre le workbook sauvegardé, il est caché, que l'application VB soit ouverte ou fermée.
2) quand je fais 1) pendant que mon application et ma forme sont ouvertes, un deuxième workbook caché y est (e.g. "Book 1"). Si j'ouvre ce deuxième workbook, soudain, le graphe qui est sur ma forme VB grossit et ne devient que partiellement visible dans l'objet OLE.
Je peux vivre sans connaître la raison exacte de ce dernier point. Cependant, mes clients n'aimeront pas avoir à faire apparaître manuellement leur workbook chaque fois qu'ils l'auront exporté.
M.K. Paquette