Communauté Informatique NDFR.net

Communauté Informatique NDFR.net (http://www.ndfr.net/forums/index.php)
-   Programmation (C/C++, Delphi, VB, etc.) (http://www.ndfr.net/forums/forumdisplay.php?f=64)
-   -   VBA sur access (http://www.ndfr.net/forums/showthread.php?t=5411)

vtchikin 15-11-2004 16:09

VBA sur access
 
J'aimerai exporter 4 pivottable vers 1 seul fichier (précis d'excel)
est-ce possible?
merci d'avance a ceux qui peuvent m'aider.
vtchikin@yahoo.fr

l'assistant à créer du code. Seulement j'aimerai l'adapter pour exporter ces pivot dans mon fichier.

sim140680 15-11-2004 16:24

Salut

Avec ce code tu peux exporter une table ACCESS en ficher EXCEL, c'est assez "bateau" mais ça marche bien (reste à vérifier, j'ai fait quelques modif à la volée):


Private Sub test_Click()
Dim db As Database
Dim qdf As QueryDef
Dim chSQL As String
Dim Name As String
Dim paramDate As Date

Name = "TEST"
Set db = CurrentDb
db.QueryDefs.Refresh


For Each qdf In db.QueryDefs
If qdf.Name = [Name] Then
db.QueryDefs.Delete qdf.[Name]
End If
Next qdf


chSQL = "SELECT [Requête].Champ1, [Requête].champ2, .... FROM [Requête] WHERE ..... ;"

Set qdf = db.CreateQueryDef([Name], chSQL)

If DCount("*", [Name]) > 0 Then

'On execute la Requête
DoCmd.OpenQuery [Name], acNormal, acEdit
'On exporte vers le fichier
DoCmd.OutputTo acOutputQuery, [Name], acFormatXLS, Path & NomFich & ".xls", False

Else
MsgBox "Il n'y a pas de donnée pour cette requête", vbInformation + vbOKOnly, "Information"
End If

End Sub

vtchikin 15-11-2004 16:36

suite vba
 
:rolleyes: est ce possible d'executer ce code pour exporter un formulaire?mon pivot table est contruit grâce à l'assistant comme un object du formulaire?

sim140680 15-11-2004 16:50

Je ne sais exporter que des tables ou des requêtes, ACCESS 97 oblige!!!
Exporter des !!???fromulaires??!! :confused:

Il te faut recuperer la requête sous forme de chaine SQL pour lancer
DoCmd.OutputTo acOutputQuery qui exporte une requête

Ou bien utiliser DoCmd.OutputTo acOutputTable pour exporter une table

il y a bien un DoCmd.OutputTo acOutputForm mais je ne sais pas l'utiliser

vtchikin 15-11-2004 17:18

merci d'avoir essayé c kool


All times are GMT +2. The time now is 00:40.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.