Bonjour,

J'essay de remetre en forme un fichier Excel par du CODE VBA (Access)

Voila mon code actuel, je ne sais pas ou se trouve l'erreur cela me semble correct) ce qui pose probléme à mon avis est la séléction de la zone à copier?

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
22
23
24
25
26
27
28
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
 
Dim bookMac As Excel.Workbook
Dim sheetMac As Excel.Worksheet
 
        '/////////////////// Attribution des valeurs
Set xlApp = New Excel.Application
xlApp.Visible = False
 
Set xlBook = xlApp.Workbooks.Open(myPath)
Set xlSheet = xlBook.Worksheets("Obsoletes")
 
Set bookMac = xlApp.Workbooks.Open("U:\Logistique\SERVICE\Alexis\Sauvegarde\Save Bureau PC 2\MISSIONS\OUTIL ACCESS\Base_Plat_Donnees\DOC IMPORT\BW_OBS_IMPORT.xls")
Set sheetMac = bookMac.Worksheets(1)
 
      '/////////////////////////////////////// Chemin du fichier macro et import
 
 
xlBook.xlSheet.Range("C33:S33").Select 'Séléction des cellule de C à S puis séléction jusqu'à la fin des données
xlBook.xlSheet.Range(Selection, Selection.End(xlDown)).Copy Destination:=sheetMac.Range("A2")  'Copie puis Coller dans le fichier de destination en dessou de l'entéte ligne 2
 
xlBook.Save
xlApp.Quit
Set wlsheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing

Merci pour votre aide

Alexis