Précédent   Forum des professionnels en informatique > Autres langages > Général Visual Basic 6 et VBScript > VBScript
VBScript Le forum d'entraide sur VBScript. Avant de poster -> La FAQ VBScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 25/01/2012, 16h32   #1
Candidat au titre de Membre du Club
 
Homme johnVSsmith Izanagi
Urbaniste
Inscription : juillet 2011
Messages : 19
Détails du profil
Informations personnelles :
Nom : Homme johnVSsmith Izanagi
Localisation : France

Informations professionnelles :
Activité : Urbaniste
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : juillet 2011
Messages : 19
Points : 14
Points : 14
Par défaut Excel : SaveAs HTML

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.


Code :
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
Même principe avec PowerPoint, et la ça marche :

Code :
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
Pour utiliser la fonction SaveAs, il faut SaveAs(nomFichier, formatSortie), mais je ne trouve pas la constante qui marche avec Excel...

Merci d'avance !
johnVSsmith est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/01/2012, 17h00   #2
Candidat au titre de Membre du Club
 
Homme johnVSsmith Izanagi
Urbaniste
Inscription : juillet 2011
Messages : 19
Détails du profil
Informations personnelles :
Nom : Homme johnVSsmith Izanagi
Localisation : France

Informations professionnelles :
Activité : Urbaniste
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : juillet 2011
Messages : 19
Points : 14
Points : 14
44 est la constante...

J'ai testé de 1 à 46 pour avoir un résultat.

J'aurais adoré que la réponse serait 42 MDR xD
johnVSsmith est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 25/01/2012, 17h18   #3
Responsable Visual Basic
 
Avatar de bbil
 
Inscription : juin 2003
Messages : 11 773
Détails du profil
Informations personnelles :
Âge : 45
Localisation : France, Ariège (Midi Pyrénées)

Informations forums :
Inscription : juin 2003
Messages : 11 773
Points : 16 854
Points : 16 854
Envoyer un message via Skype™ à bbil
Bonjour,

pour trouver la valeur d'une constante excel ... une petite recherche dans l'aide en ligne pour trouver le nom de la constante .. puis dans la fenêtre exécution de l'éditeur VBA CTRL+G tu saisi :

bbil est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 00h44.


 
 
 
 
Partenaires

Hébergement Web