Bonjour à tous,
Je souhaite enregistrer au format HTML un classeur Excel mais ça ne fonctionne pas, contrairement à un document Word ou une présentation PPT.
Même principe avec PowerPoint, et la ça marche :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Dim nomApplication, objExcel, CheminFichier, Extension, objFeuille, objClasseur nomApplication = "Excel" ' Création de l'objet Excel Set objExcel = CreateObject(nomApplication + ".Application") With objExcel ' Vrai : Excel visible; False: Excel invisible .Visible = True ' Ouvre le document Excel .Workbooks.Open(CheminFichier + "." + Extension) ' Le fichier ouvert devient le document actif Set objFeuille = .ActiveWorkbook Set objClasseur = .ActiveSheet ' Sauvegarde du fichier en tant que HTML objFeuille.SaveAs fichierHTML, 14 ' Ferme le document actif objFeuille.Close ' Ferme Excel .Quit End With
Pour utiliser la fonction SaveAs, il faut SaveAs(nomFichier, formatSortie), mais je ne trouve pas la constante qui marche avec Excel...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 Dim nomApplication, objPres , CheminFichier, Extension, objPres nomApplication = "PowerPoint" ' Création de l'objet PowerPoint Set objPowerPoint= CreateObject(nomApplication + ".Application") With objPowerPoint ' Vrai : PowerPoint visible; False: PowerPoint invisible .Visible = True ' Erreur si l'on rend invisible ' Ouverture du diaporama .Presentations.Open(CheminFichier + "." + Extension) ' La présentation ouverte devient la présentation active Set objPres = .ActivePresentation ' Sauvegarde du fichier en tant que HTML objPres.SaveAs fichierHTML, 14 ' 14 = format HTML ' Ferme la présentation active objPres.Close ' Ferme PowerPoint .Quit End With
Merci d'avance !
Partager