xlBook = GetObject(sPathAndFileName, "Excel.Aplication")
If Err.Number <> 0 Then
Err.Clear
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open(sPathAndFileName)
Else
Set xlApp = GetObject(, "Excel.Application")
End If
vercomax
Messages postés547Date d'inscriptionmercredi 28 juillet 2004StatutMembreDernière intervention11 septembre 20132 15 janv. 2007 à 20:56
merci pour ta réponse Mortalino, aucune erreur pour le code que tu me donnes, seul ombre, et de taille: çà ouvre en fait autant de fois que je lances ces lignes de code, et donc çà ne tient pas compte du fait que "C:\Chemin complet\nom fichier.xls" soit déjà ouvert.
je tourne en rond
bah, je finirai bien par trouver, mais çà dure
merci encore.
xlBook = GetObject(sPathAndFileName, "Excel.Aplication")
If Err.Number <> 0 Then
Err.Clear
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open(sPathAndFileName)
Else
Set xlApp = GetObject(, "Excel.Application")
End If
On Error GoTo 0: OpenFile = True 'ICI
End If 'et le End If pour finir
vercomax
Messages postés547Date d'inscriptionmercredi 28 juillet 2004StatutMembreDernière intervention11 septembre 20132 15 janv. 2007 à 21:45
idem, je l'ai lancé 2 fois, il ouvre 2 fois le fichier. j'ai fait un cop-col (sauf nom du fichier), pas d'erreur compilation, mais il ouvre 2 fois la feuille.
je pensais ptet rechercher dans un paramètres à fournir lors du :xlBook = docexcel.Workbooks.Open(sPathAndFileName)