Excel print with xojo

Bonjour
J’envoie des donnees dans un fichier excel,
-1) Je voudrais pouvoir definir la zone a imprimer avec xojo
-2) je souhaiterai lancer l’impression via xojo

-3) refermer le fichier, sans enregistrer les modifications en auto via xojo

Est-ce possible, vue le nombre de classe je pense que oui, mais je ne sais pas exactement a quoi elle correspondent toutes, ni les arguments qu’elles attendent…

Merci…!!

Hello Julien,

This pushbutton1.Action event code adds data in cells A1 to B2 with the string “text”. Cells A1 to B2 are selected for printing and data is sent to the printer. Excel is then closed without saving. This works with Windows 10, Xojo 2017 r1.1.

The Xojo plugin must be installed. Copy C:\Program Files (x86)\Xojo\Xojo 2017r1.1\Extras\Office Automation\MSOfficeAutomation.rbx to C:\Program Files (x86)\Xojo\Xojo 2017r1.1\Plugins\\MSOfficeAutomation.rbx

[code]Sub Action() Handles Action
Dim excel as new ExcelApplication
excel.Workbooks.Add
excel.visible = true

//New data in cells
excel.Range(“A1:B2”).Value = “text”

//Print cell data
excel.ActiveSheet.Range(“A1:B2”).Printout

//Close excel
excel.ActiveWorkbook.close false
excel.Quit
excel = nil

Exception err as OLEException
MsgBox err.message

End Sub
[/code]

:slight_smile: