Quitter excel et ouvrir access
trucfud
-
trucfud -
trucfud -
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
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:
- Quitter excel et ouvrir access
- Word et excel gratuit - Guide
- Comment ouvrir un fichier epub ? - Guide
- Liste déroulante excel - Guide
- Ouvrir fichier .bin - Guide
- Forcer à quitter - Guide