Quitter excel et ouvrir access

Fermé
trucfud - 11 août 2008 à 16:51
 trucfud - 12 août 2008 à 12:48
Bonjour,

je travaille sur access, j'utilise le code suivant pour ouvrir excel :


' Late Binding (Needs no reference set)
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String


' Create a new Excel instance
Set oXL = CreateObject("Excel.Application")


' Only XL 97 supports UserControl Property
On Error Resume Next
oXL.UserControl = True
On Error GoTo 0


' Full path of excel file to open
On Error GoTo ErrHandle
sFullPath = CurrentProject.Path & "I:\03. Project Controlling\01. NL Maintenance\04_Database\db test\DB look up Files - Access Master Database\Trending charts\Charts.xls"


' Open it
With oXL
.Visible = True
.Workbooks.Open ("I:\03. Project Controlling\01. NL Maintenance\04_Database\db test\DB look up Files - Access Master Database\Trending charts\Charts.xls")

End With


ErrExit:
Set oXL = Nothing
Exit Sub

ErrHandle:
oXL.Visible = False
MsgBox Err.Description
GoTo ErrExit
End Sub

cela fonctionne tres bien, mais sur excel, je n'arrive pas a fermer l'application malgre plusieurs code vb sur mon excel.
voila mon dernier code, qui me ferme mon classeur ms pas l'appplication:

Private Sub CommandButton5_Click()
ActiveWorkbook.Close True

ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
'quit excel
xlobject.Quit
Set xlbook = Nothing
Set xlobject = Nothing
Application.Quit
End Sub


voila, Y aurait il quelqu'un qui pourrait me venir en aide, je debute vraiment sur VBA.

Merci a tous
A voir également:

1 réponse

Quelqu'un pourrait il juste me dire s'il voit une erreur dans ce code

Private Sub CommandButton5_Click()
ActiveWorkbook.Close True

ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
'quit excel
xlobject.Quit
Set xlbook = Nothing
Set xlobject = Nothing
Application.Quit
End Sub
0