SOUCI SUR UN COPIER COLLER FEUILLE A CLASSEUR A à FEUILLE B CLASSEUR B

CARL6 Messages postés 1 Date d'inscription mercredi 21 avril 2004 Statut Membre Dernière intervention 21 avril 2004 - 21 avril 2004 à 17:21
cs_snowmax Messages postés 1 Date d'inscription lundi 17 mars 2003 Statut Membre Dernière intervention 28 mai 2004 - 28 mai 2004 à 11:33
Ma fonction ci-dessous ne marche pas, est ce que quel'qu'un à une idée.

Merci d'avance

Function Importation_donnees_Rnd(LC As String, Indicateurlivraisonsclientsfournisseurs As String, AN_DELAIC As String, OC As String)


Set Fichier_xls_Source = GetObject(LC)
Set Fichier_xls_Source = GetObject(, "Excel.application")

Fichier_xls_Source.Application.Visible = True


Fichier_xls_Source.Application.Workbooks.Open Filename:=LC


Fichier_xls_Source.Application.ActiveWorkbook.Worksheets(AN_DELAIC).Activate
Fichier_xls_Source.Application.ActiveWorkbook.Worksheets(AN_DELAIC).Cells.Select
Fichier_xls_Source.Application.Selection.Copy


Set Fichier_xls_dest = CreateObject("Excel.application")

Fichier_xls_dest.DisplayAlerts = False
Fichier_xls_dest.Workbooks.Open Filename:=Indicateurlivraisonsclientsfournisseurs, editable:=True
Fichier_xls_dest.Visible = True


Fichier_xls_dest.Application.Worksheets(OC).Activate

Fichier_xls_dest.Application.Worksheets(OC).Cells.Select
Fichier_xls_dest.Application.Worksheets(OC).Paste

Fichier_xls_dest.Application.DisplayAlerts = False
Fichier_xls_dest.ActiveWorkbook.SaveAs Filename:=Indicateurlivraisonsclientsfournisseurs
Fichier_xls_dest.Application.Quit
Fichier_xls_dest.Application.DisplayAlerts = True

Fichier_xls_Source.Application.DisplayAlerts = False
Fichier_xls_Source.Application.Quit
Fichier_xls_Source.Application.DisplayAlerts = True

Set Fichier_xls_Source = Nothing
Set Fichier_xls_dest = Nothing

End Function

1 réponse

cs_snowmax Messages postés 1 Date d'inscription lundi 17 mars 2003 Statut Membre Dernière intervention 28 mai 2004
28 mai 2004 à 11:33
Salut CARL6

J'ai essayé ton code, et avec quelques modifs ça a l'air de marcher :

Il y avait une erreur au niveau de getobject, donc remplace ça
par
Set Fichier_xls_Source =createobject("Excel.application")

Ensuite, si le fichier source n'existe pas, il faut entrer :
Fichier_xls_Source.Application.Workbooks.new
(comme je ne sais pas si tu le modifies ou le crée)

Enfin pour la sectioncollage sur le fichier source, essaie
Fichier_xls_dest.Application.activeSheet.Activate
Fichier_xls_dest.Application.ActiveSheet.Cells.Select
Fichier_xls_dest.Application.ActiveSheet.Paste

Voila, j'espère que ça t'aidera !! 8-)
Ciao

nothing won't cure a good day of snowboarding
0
Rejoignez-nous