OVH Cloud OVH Cloud

MAJ d'un fichier excel en fonction d'un message

1 réponse
Avatar
jpurtado
Bonjour,

1/ Je voudrais ouvrir un fichier Excel existant
2/ Y ajouter un champs du message Oulook
3/ Fermer le fichier Excel en sauvegardant

J'ai trouv=E9 ce code qui cr=E9e un nouveau fichier mais est'il possible
d'ouvrir un fichier d=E9j=E0 existant

Set ExcelSheet =3D CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible =3D True
ExcelSheet.Application.Cells(1, 1).Value =3D "essai"
ExcelSheet.SaveAs "C:\tmp\TEST2.XLS"
ExcelSheet.Application.Quit
Set ExcelSheet =3D Nothing

Merci A+

1 réponse

Avatar
Oliv'
* que je salut a écrit *:
Bonjour,

1/ Je voudrais ouvrir un fichier Excel existant
2/ Y ajouter un champs du message Oulook
3/ Fermer le fichier Excel en sauvegardant

J'ai trouvé ce code qui crée un nouveau fichier mais est'il possible
d'ouvrir un fichier déjà existant


voici un exemple.

'Déclaration des variables
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel

Set appExcel = CreateObject("Excel.Application")
appExcel.Visible = true
'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open(repertoire & objAtt.FileName)
'wsExcel correspond à la première feuille du fichier
Set wsExcel = wbExcel.Worksheets(1)


'ici le code


' fin de la macro et fermeture de excel
wbExcel.close
appExcel.quit
set appExcel = nothing
Set wbExcel = nothing
Set WsExcel =nothing



--
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Have a nice day
Oliv'
Pour me joindre : http://cerbermail.com/?V8r2o1YHl4
les sites références:
Excel :http://www.excelabo.net http://xcell05.free.fr/
http://dj.joss.free.fr/
http://frederic.sigonneau.free.fr/ http://www.excel-vba-francais.com/
Word : http://faqword.free.fr/
Outlook : http://faq.outlook.free.fr/
les archives : http://groups.google.com/group/microsoft.public.fr.outlook
OE6 : http://www.faqoe.com/
Sql : http://sqlpro.developpez.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~