Bonjour,
Depuis Access j'ouvre un fichieer Excel, je fais des manip dans le fichier
Excel (MANUELLEMENT) et je ferme Excel manuellement. Mes opérations se
déroulent bien la 1ère fois, mais j'ai un message d'erreur à la seconde fois.
Malgré la fermeture manuelle d'Excel, il reste une instance Excel ouverte
qui, je pense, pose ce problème. Je sais fermer Excel depusi Access, mais
dans mon cas j'ai absolument besoin d'intervenir manuellement sur le fichier
; il faudrait que j'arrive à fermer l'instance ouverte lorsque je retourne
dans Access.
Ci dessous mon code.
Mercid 'avance
Antoine
Private Sub Commande0_Click()
'SAISIR LES REGLAGES
Dim Ligne As Integer
Dim colonne As Integer
Dim dernLigne As Long
Dim oApp As Excel.Application
Dim wbk As Excel.Workbook
Dim sht As Excel.Sheets
Set oApp = New Excel.Application
With oApp
.Visible = True
'On Error Resume Next
strChemin = "D:\Applications\INTRANET\Applications ...."
Set wbk = oApp.Workbooks.Open(strChemin)
With oApp.Sheets("Base de données ARTICLE").Select
oApp.Selection.AutoFilter Field:=2
'détermine le numéro de la dernière ligne utilisée
dernLigne = Range("A1").End(xlDown).Row
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Blaise Cacramp
Selon : Bonjour ou bonsoir
Erreur 1004 ? Il faut bien tout référencer
de mémoire (attention aux points cells et range) Private Sub Commande0_Click() 'SAISIR LES REGLAGES Dim Ligne As Integer Dim colonne As Integer Dim dernLigne As Long Dim sXlChemin As String
Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet
sXlChemin = "D:ApplicationsINTRANETApplications ...." Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open(sXlChemin) xlApp.Visible = True Set xlSheet = xlBook.Worksheets("Base de données ARTICLE")
With xlSheet
.cells.AutoFilter Field:=2 'détermine le numéro de la dernière ligne utilisée dernLigne = .Range("A1").End(xlDown).Row
'[.....] Manip sur Excel
End With
Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing End Sub
Cdt, Blaise ---- ---- ----
"Antoine" a écrit dans le message de news:
Bonjour, Depuis Access j'ouvre un fichieer Excel, je fais des manip dans le fichier Excel (MANUELLEMENT) et je ferme Excel manuellement. Mes opérations se déroulent bien la 1ère fois, mais j'ai un message d'erreur à la seconde fois. Malgré la fermeture manuelle d'Excel, il reste une instance Excel ouverte qui, je pense, pose ce problème. Je sais fermer Excel depusi Access, mais dans mon cas j'ai absolument besoin d'intervenir manuellement sur le fichier ; il faudrait que j'arrive à fermer l'instance ouverte lorsque je retourne dans Access. Ci dessous mon code. Mercid 'avance Antoine
Private Sub Commande0_Click()
'SAISIR LES REGLAGES Dim Ligne As Integer Dim colonne As Integer Dim dernLigne As Long Dim oApp As Excel.Application Dim wbk As Excel.Workbook Dim sht As Excel.Sheets
Set oApp = New Excel.Application
With oApp
.Visible = True 'On Error Resume Next
strChemin = "D:ApplicationsINTRANETApplications ...." Set wbk = oApp.Workbooks.Open(strChemin)
With oApp.Sheets("Base de données ARTICLE").Select
oApp.Selection.AutoFilter Field:=2 'détermine le numéro de la dernière ligne utilisée dernLigne = Range("A1").End(xlDown).Row
[.....] Manip sur Excel
End With
End With
End Sub
Selon : Bonjour ou bonsoir
Erreur 1004 ? Il faut bien tout référencer
de mémoire (attention aux points cells et range)
Private Sub Commande0_Click()
'SAISIR LES REGLAGES
Dim Ligne As Integer
Dim colonne As Integer
Dim dernLigne As Long
Dim sXlChemin As String
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
sXlChemin = "D:ApplicationsINTRANETApplications ...."
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(sXlChemin)
xlApp.Visible = True
Set xlSheet = xlBook.Worksheets("Base de données ARTICLE")
With xlSheet
.cells.AutoFilter Field:=2
'détermine le numéro de la dernière ligne utilisée
dernLigne = .Range("A1").End(xlDown).Row
'[.....] Manip sur Excel
End With
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
Cdt, Blaise
---- ---- ----
"Antoine" <Antoine@discussions.microsoft.com> a écrit dans le message de
news: C6F5B15E-56D4-48E5-89FF-1DB971FE387F@microsoft.com...
Bonjour,
Depuis Access j'ouvre un fichieer Excel, je fais des manip dans le fichier
Excel (MANUELLEMENT) et je ferme Excel manuellement. Mes opérations se
déroulent bien la 1ère fois, mais j'ai un message d'erreur à la seconde
fois.
Malgré la fermeture manuelle d'Excel, il reste une instance Excel ouverte
qui, je pense, pose ce problème. Je sais fermer Excel depusi Access, mais
dans mon cas j'ai absolument besoin d'intervenir manuellement sur le
fichier
; il faudrait que j'arrive à fermer l'instance ouverte lorsque je retourne
dans Access.
Ci dessous mon code.
Mercid 'avance
Antoine
Private Sub Commande0_Click()
'SAISIR LES REGLAGES
Dim Ligne As Integer
Dim colonne As Integer
Dim dernLigne As Long
Dim oApp As Excel.Application
Dim wbk As Excel.Workbook
Dim sht As Excel.Sheets
Set oApp = New Excel.Application
With oApp
.Visible = True
'On Error Resume Next
strChemin = "D:ApplicationsINTRANETApplications ...."
Set wbk = oApp.Workbooks.Open(strChemin)
With oApp.Sheets("Base de données ARTICLE").Select
oApp.Selection.AutoFilter Field:=2
'détermine le numéro de la dernière ligne utilisée
dernLigne = Range("A1").End(xlDown).Row
de mémoire (attention aux points cells et range) Private Sub Commande0_Click() 'SAISIR LES REGLAGES Dim Ligne As Integer Dim colonne As Integer Dim dernLigne As Long Dim sXlChemin As String
Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet
sXlChemin = "D:ApplicationsINTRANETApplications ...." Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open(sXlChemin) xlApp.Visible = True Set xlSheet = xlBook.Worksheets("Base de données ARTICLE")
With xlSheet
.cells.AutoFilter Field:=2 'détermine le numéro de la dernière ligne utilisée dernLigne = .Range("A1").End(xlDown).Row
'[.....] Manip sur Excel
End With
Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing End Sub
Cdt, Blaise ---- ---- ----
"Antoine" a écrit dans le message de news:
Bonjour, Depuis Access j'ouvre un fichieer Excel, je fais des manip dans le fichier Excel (MANUELLEMENT) et je ferme Excel manuellement. Mes opérations se déroulent bien la 1ère fois, mais j'ai un message d'erreur à la seconde fois. Malgré la fermeture manuelle d'Excel, il reste une instance Excel ouverte qui, je pense, pose ce problème. Je sais fermer Excel depusi Access, mais dans mon cas j'ai absolument besoin d'intervenir manuellement sur le fichier ; il faudrait que j'arrive à fermer l'instance ouverte lorsque je retourne dans Access. Ci dessous mon code. Mercid 'avance Antoine
Private Sub Commande0_Click()
'SAISIR LES REGLAGES Dim Ligne As Integer Dim colonne As Integer Dim dernLigne As Long Dim oApp As Excel.Application Dim wbk As Excel.Workbook Dim sht As Excel.Sheets
Set oApp = New Excel.Application
With oApp
.Visible = True 'On Error Resume Next
strChemin = "D:ApplicationsINTRANETApplications ...." Set wbk = oApp.Workbooks.Open(strChemin)
With oApp.Sheets("Base de données ARTICLE").Select
oApp.Selection.AutoFilter Field:=2 'détermine le numéro de la dernière ligne utilisée dernLigne = Range("A1").End(xlDown).Row