Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access > VBA Access
VBA Access Le forum pour les questions relatives au code VBA sous Access, et à son environnement de développement VBE.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 05/01/2012, 11h06   #1
Candidat au titre de Membre du Club
 
Inscription : décembre 2004
Messages : 137
Détails du profil
Informations forums :
Inscription : décembre 2004
Messages : 137
Points : 12
Points : 12
Par défaut Ouverture fichier excel actualisé

Bonjour, j'ai un bouton dans un formulaire access pour ouvrir un fichier excel mais celui-ci ne s'actualise pas.
Quand je l'ouvre dans l'explorateur windows, il s'actualise.

Avez-vous une idée?


Code :
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
29
30
31
32
33
34
35
36
37
38
39
Sub OpenSpecific_xlFile()
     '   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 & "\timesheet_2012.xls"
 
 
     '   Open it
    With oXL
        .Visible = True
        .Workbooks.Open (sFullPath)
    End With
 
 
ErrExit:
    Set oXL = Nothing
    Exit Sub
 
ErrHandle:
    oXL.Visible = False
    MsgBox Err.Description
    GoTo ErrExit
End Sub
gregius est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 20h43   #2
Rédacteur
 
Avatar de LedZeppII
 
Homme
Maintenance données produits
Inscription : décembre 2005
Messages : 3 939
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France, Yvelines (Île de France)

Informations professionnelles :
Activité : Maintenance données produits
Secteur : Distribution

Informations forums :
Inscription : décembre 2005
Messages : 3 939
Points : 6 278
Points : 6 278
Bonjour,

Tu peux essayer comme ça :
Code :
1
2
3
4
5
6
7
8
9
10
11
Sub OpenSpecific_xlFile()
Dim oShell As Object
Dim strFichierAouvrir As String
 
Set oShell = CreateObject("Shell.Application")
 
strFichierAouvrir = CurrentProject.Path & "\timesheet_2012.xls"
oShell.Open CVar(strFichierAouvrir)
 
Set oShell = Nothing
End Sub
A+
LedZeppII est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h14.


 
 
 
 
Partenaires

Hébergement Web