Ouvrir un fichier via une référence dans une cellule
9 réponses
Gaspareau
Bonjour
J'ai tenté de trouver mais je n'ai rien vu pour résoudre mon problème
je fais donc appel aux Ex-cel-perts
Je m'explique
J'ai souvent à travailler des fichier dans lequel se trouve des
cellules qui ont une référence externe
exemple en C1 j'ai
='F:\03 TRAVAUX PUBLICS\06.03.00 PROMOTEURS\06.03.04-000 SECTEUR 4
\Protocole\Reg 1061\[Boise.xls]Explications'!$F$58
Je voudrais avoir l'option via une commande dans le menu clic droit de la
cellule
d'ouvrir directement le fichier spécifié dans l'adresse de la cellule.
Présentement je dois noté l'adresse pour ouvrir le bon fichier !!
Notez que j'ai raccourci l'adresse complète pour mon exemple !!!
C'est faisable ? Quelqu'un a déjà réussi l'exploit ?
Ton fichier exemple fait un bon bout de chemin mais il y a encore un os
Dans ton exemple, l'adresse est écrite dans la cellule source alors que moi c'est une référence qui est la source vers laquelle je veux aller
Donc ton exemple : c:marketinggamme_bureautique.xls Alors que moi j'aurais : c:marketing[gamme_bureautique.xls]Feuil1'!$A$1
Je dois donc "extraire" le chemin de l'adresse de la cellule en référence
C'est plus clair ?
Merci beaucoup
Dany
"JB" a écrit dans le message de news:
Bonjour,
http://cjoint.com/?evqUtmTric
Private Sub Worksheet_Activate() Set temp = CommandBars("cell").Controls.Add temp.Caption = "Ouvre Fichier" temp.OnAction = "MaMacro" temp.FaceId = 120 temp.BeginGroup = True End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Sub mamacro() If ActiveCell <> "" Then Workbooks.Open Filename:¬tiveCell End Sub
Cordialement JB
JB
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate() Set temp = CommandBars("cell").Controls.Add temp.Caption = "Ouvre Fichier" temp.OnAction = "MaMacro" temp.FaceId = 120 temp.BeginGroup = True End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Sub mamacro() If ActiveCell <> "" Then nf = ActiveCell p = InStr(nf, "]") If p > 0 Then nf = Left(nf, p - 1) nf = Application.Substitute(nf, "[", "") Workbooks.Open Filename:=nf End If End Sub
JB
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate()
Set temp = CommandBars("cell").Controls.Add
temp.Caption = "Ouvre Fichier"
temp.OnAction = "MaMacro"
temp.FaceId = 120
temp.BeginGroup = True
End Sub
Private Sub Worksheet_Deactivate()
Application.CommandBars("Cell").Reset
End Sub
Sub mamacro()
If ActiveCell <> "" Then
nf = ActiveCell
p = InStr(nf, "]")
If p > 0 Then nf = Left(nf, p - 1)
nf = Application.Substitute(nf, "[", "")
Workbooks.Open Filename:=nf
End If
End Sub
Private Sub Worksheet_Activate() Set temp = CommandBars("cell").Controls.Add temp.Caption = "Ouvre Fichier" temp.OnAction = "MaMacro" temp.FaceId = 120 temp.BeginGroup = True End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Sub mamacro() If ActiveCell <> "" Then nf = ActiveCell p = InStr(nf, "]") If p > 0 Then nf = Left(nf, p - 1) nf = Application.Substitute(nf, "[", "") Workbooks.Open Filename:=nf End If End Sub
JB
Gaspareau
Merci beaucoup encore une fois c'Est très apprécié
Dans ton exemple, tu as écris en dur le chemin alors que moi c'Est une référence donc ='C:....
Dans mon classeur je ne vois que le résultat de cette cellule il s'agit d'un résultat qui provient d'un autre fichier situé ailleurs sur notre réseau.
http://cjoint.com/?evtNNHn8Iz
MErci
"JB" a écrit dans le message de news:
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate() Set temp = CommandBars("cell").Controls.Add temp.Caption = "Ouvre Fichier" temp.OnAction = "MaMacro" temp.FaceId = 120 temp.BeginGroup = True End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Sub mamacro() If ActiveCell <> "" Then nf = ActiveCell p = InStr(nf, "]") If p > 0 Then nf = Left(nf, p - 1) nf = Application.Substitute(nf, "[", "") Workbooks.Open Filename:=nf End If End Sub
JB
Merci beaucoup encore une fois
c'Est très apprécié
Dans ton exemple, tu as écris en dur le chemin
alors que moi c'Est une référence donc ='C:....
Dans mon classeur je ne vois que le résultat de cette cellule
il s'agit d'un résultat qui provient d'un autre fichier situé ailleurs
sur notre réseau.
http://cjoint.com/?evtNNHn8Iz
MErci
"JB" <boisgontier@hotmail.com> a écrit dans le message de
news:1145636167.374571.235450@i39g2000cwa.googlegroups.com...
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate()
Set temp = CommandBars("cell").Controls.Add
temp.Caption = "Ouvre Fichier"
temp.OnAction = "MaMacro"
temp.FaceId = 120
temp.BeginGroup = True
End Sub
Private Sub Worksheet_Deactivate()
Application.CommandBars("Cell").Reset
End Sub
Sub mamacro()
If ActiveCell <> "" Then
nf = ActiveCell
p = InStr(nf, "]")
If p > 0 Then nf = Left(nf, p - 1)
nf = Application.Substitute(nf, "[", "")
Workbooks.Open Filename:=nf
End If
End Sub
Merci beaucoup encore une fois c'Est très apprécié
Dans ton exemple, tu as écris en dur le chemin alors que moi c'Est une référence donc ='C:....
Dans mon classeur je ne vois que le résultat de cette cellule il s'agit d'un résultat qui provient d'un autre fichier situé ailleurs sur notre réseau.
http://cjoint.com/?evtNNHn8Iz
MErci
"JB" a écrit dans le message de news:
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate() Set temp = CommandBars("cell").Controls.Add temp.Caption = "Ouvre Fichier" temp.OnAction = "MaMacro" temp.FaceId = 120 temp.BeginGroup = True End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Sub mamacro() If ActiveCell <> "" Then nf = ActiveCell p = InStr(nf, "]") If p > 0 Then nf = Left(nf, p - 1) nf = Application.Substitute(nf, "[", "") Workbooks.Open Filename:=nf End If End Sub
Si tu savais le temps fou que tu me fera économiser
MERCI !!
"JB" a écrit dans le message de news:
Modifier nf : nf = Mid(ActiveCell.Formula, 3)
http://cjoint.com/?evvTR0cLDF
JB
Ange Ounis
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Une petite remarque sur cette proc, JB. Elle supprime toutes modifications apportées par l'utilisateur au menu standard, et pas seulement celle que tu viens d'y apporter. Beaucoup de gens n'aiment pas trop qu'on fasse ainsi le ménage chez eux sans leur demander leur avis :( Ce n'est certes qu'un avis personnel mais je préfère pour remettre en ordre ce genre de code :
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Controls("Ouvre Fichier").Delete End Sub
---------- Ange Ounis ----------
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate() Set temp = CommandBars("cell").Controls.Add temp.Caption = "Ouvre Fichier" temp.OnAction = "MaMacro" temp.FaceId = 120 temp.BeginGroup = True End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Sub mamacro() If ActiveCell <> "" Then nf = ActiveCell p = InStr(nf, "]") If p > 0 Then nf = Left(nf, p - 1) nf = Application.Substitute(nf, "[", "") Workbooks.Open Filename:=nf End If End Sub
JB
Private Sub Worksheet_Deactivate()
Application.CommandBars("Cell").Reset
End Sub
Une petite remarque sur cette proc, JB.
Elle supprime toutes modifications apportées par l'utilisateur au menu standard,
et pas seulement celle que tu viens d'y apporter. Beaucoup de gens n'aiment pas
trop qu'on fasse ainsi le ménage chez eux sans leur demander leur avis :(
Ce n'est certes qu'un avis personnel mais je préfère pour remettre en ordre ce
genre de code :
Private Sub Worksheet_Deactivate()
Application.CommandBars("Cell").Controls("Ouvre Fichier").Delete
End Sub
----------
Ange Ounis
----------
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate()
Set temp = CommandBars("cell").Controls.Add
temp.Caption = "Ouvre Fichier"
temp.OnAction = "MaMacro"
temp.FaceId = 120
temp.BeginGroup = True
End Sub
Private Sub Worksheet_Deactivate()
Application.CommandBars("Cell").Reset
End Sub
Sub mamacro()
If ActiveCell <> "" Then
nf = ActiveCell
p = InStr(nf, "]")
If p > 0 Then nf = Left(nf, p - 1)
nf = Application.Substitute(nf, "[", "")
Workbooks.Open Filename:=nf
End If
End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Une petite remarque sur cette proc, JB. Elle supprime toutes modifications apportées par l'utilisateur au menu standard, et pas seulement celle que tu viens d'y apporter. Beaucoup de gens n'aiment pas trop qu'on fasse ainsi le ménage chez eux sans leur demander leur avis :( Ce n'est certes qu'un avis personnel mais je préfère pour remettre en ordre ce genre de code :
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Controls("Ouvre Fichier").Delete End Sub
---------- Ange Ounis ----------
http://cjoint.com/?evspVF7YaZ
Private Sub Worksheet_Activate() Set temp = CommandBars("cell").Controls.Add temp.Caption = "Ouvre Fichier" temp.OnAction = "MaMacro" temp.FaceId = 120 temp.BeginGroup = True End Sub
Private Sub Worksheet_Deactivate() Application.CommandBars("Cell").Reset End Sub
Sub mamacro() If ActiveCell <> "" Then nf = ActiveCell p = InStr(nf, "]") If p > 0 Then nf = Left(nf, p - 1) nf = Application.Substitute(nf, "[", "") Workbooks.Open Filename:=nf End If End Sub