VBScript: ouvrir fichier Excel avec Notify

H

Hugo

Guest
Bonjour à tous et toutes,

Je cherche à pouvoir ouvrir un fichier Excel (depuis répertoire partagé)depuis plusieurs PC.
(PC-A) ouvre fichier Excel en "lecture/écriture", puis (PC-B) l'ouvre,après, en "lecture seul". Puis (PC-A) fais des modifs, enregistre puis ferme fichier Excel donc (PC-B) reçoit acquitement clique sur case pour possible utilisation fichier Excel en "lecture/écriture" donc cliquer sur case mais la erreur Excel ne s'ouvre pas et il faut une "Récupération du document".

==>>Voici VBScript "version1" utilisé:
Set appXl = CreateObject("Excel.Application")
With appXl
.Workbooks.Open "\\Répertoire\fichier.xls",Notify=1
.Visible = True
End With
Set appXl = Nothing

==>>Voici VBScript "version2" utilisé:
Set appXl = CreateObject("Excel.Application")
If appXl.Workbooks.Open("\\Répertoire\fichier.xls").ReadOnly <> False Then
MsgBox("Le fichier Excel est en cours d'utilisation, veuillez patienter !!!")
Else
With appXl
.Workbooks.Open "\\Répertoire\fichier.xls",Notify=1
.Visible = True
End With
End If
Set appXl = Nothing

Je n'arrive pas à comprendre pourquoi Excel s'ouvre avec une erreur de "Récupération du document". Quelqu'un peut-il m'aider????
Est-ce le bon codage ???
Je n'y comprend plus RIEN du TOUT !!!!!

Bien à vous
Merci d'avance
Au revoir et bonne journée
 
@

@+Thierry

Guest
Bonjour Hugo, le Forum

Je n'ai pas le temps de tester en VBS mais je pense que tu devrais essayer de passer aussi dans la Méthode Open le paramètre "CorruptLoad"... avec la constante "xlNormalLoad"

Voici ce que dit l'aide, désolé je suis en version américaine :

CorruptLoad Optional Variant. Can be one of the following constants: xlNormalLoad, xlRepairFile and xlExtractData. The Default behavior if no value is specified is usually normal but may be safe load or data recovery, if Excel has already attempted to open the file. The first attempt is normal. If Excel stops operating while opening the file the second attempt is safe load. If Excel again stops operating the next attempt is data recovery.

Bon Appétit
@+Thierry
 
H

Hugo

Guest
Bonjour @+Thierry,

Tout d'abord, merci bien de vouloir t'interresser à mon problème
J'ai testé ce que tu m'as indiqué, voici le code dans ma fonction Open
.Workbooks.Open "\\répertoire\fichier.xls",Notify=1,CorruptLoad

Mais je ne sais pas joindre en VBScript la constante xlNormalLoad à CorruptLoad

Je ne suis pas bien doué j'ai testé mais rien de mieux donc ... est-ce que tu aurais d'autre info ou tu aurais pu tester cela ???

Merci d'avance
Bien à toi
Au revoir et bonne journée
 
@

@+Thierry

Guest
Re Bonjour Hugo, le Forum

La Syntax en VBS (pas en VBA) devrait s'écrire ainsi :

Dim appxl

Set appXl = CreateObject("Excel.Application")

With AppXl
.Workbooks.Open "C:\C\Test.xls", Notify=True, CorruptLoad=xlNormalLoad
.Visible = True
End With

Bon Aprèm
@+Thierry
 

Discussions similaires

Statistiques des forums

Discussions
312 389
Messages
2 087 925
Membres
103 676
dernier inscrit
Haiti