Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

fermeture d'un fichier texte

3 réponses
Avatar
inès
Bonjour

La macro ci-dessous me permet d'ouvrire un fichier texte. Comment faire pour
fermer se fichier automatiquement une fois que les données ont été récoltées.

mille merci

Inès

Dim NbChar As Integer
Dim Chemin As String
Dim Fichier As Variant

Chemin = "C:\Program Files\TMI Software\ValiVacq 4.3.2\"
Do
Fichier = Application.InputBox(Prompt:="dernier 4 chiffres", Type:=2)
If TypeName(Fichier) = "Boolean" Then
MsgBox "opération annulée."
Exit Sub
End If
Loop Until Len(CStr(Trim(Fichier))) = 4
Fichier = "*" & Fichier & "*.txt"

If Dir(Chemin & Fichier) = "" Then
MsgBox "Fichier inexistant."
Exit Sub
Else
Workbooks.OpenText Chemin & Fichier
End If

3 réponses

Avatar
Daniel.C
Bonjour.
Si j'ai bien compris :
Activeworkbook.close
Cordialement.
Daniel
"inès" a écrit dans le message de news:

Bonjour

La macro ci-dessous me permet d'ouvrire un fichier texte. Comment faire
pour
fermer se fichier automatiquement une fois que les données ont été
récoltées.

mille merci

Inès

Dim NbChar As Integer
Dim Chemin As String
Dim Fichier As Variant

Chemin = "C:Program FilesTMI SoftwareValiVacq 4.3.2"
Do
Fichier = Application.InputBox(Prompt:="dernier 4 chiffres", Type:=2)
If TypeName(Fichier) = "Boolean" Then
MsgBox "opération annulée."
Exit Sub
End If
Loop Until Len(CStr(Trim(Fichier))) = 4
Fichier = "*" & Fichier & "*.txt"

If Dir(Chemin & Fichier) = "" Then
MsgBox "Fichier inexistant."
Exit Sub
Else
Workbooks.OpenText Chemin & Fichier
End If


Avatar
inès
Bonjour Daniel.C

J'ai une feuille excel (Feuille1) ouverte et la macro m'ouvre un fichier text.
quand j'utilise la syntax Activeworkbook.close, la feuille excel (feuille1)
se ferme
mais pas l'application que la macro a ouvert. j'aimerai seulement fermer
l'application.

j'espère que mes explications sont maintenant plus claire.

Louis


Bonjour.
Si j'ai bien compris :
Activeworkbook.close
Cordialement.
Daniel
"inès" a écrit dans le message de news:

Bonjour

La macro ci-dessous me permet d'ouvrire un fichier texte. Comment faire
pour
fermer se fichier automatiquement une fois que les données ont été
récoltées.

mille merci

Inès

Dim NbChar As Integer
Dim Chemin As String
Dim Fichier As Variant

Chemin = "C:Program FilesTMI SoftwareValiVacq 4.3.2"
Do
Fichier = Application.InputBox(Prompt:="dernier 4 chiffres", Type:=2)
If TypeName(Fichier) = "Boolean" Then
MsgBox "opération annulée."
Exit Sub
End If
Loop Until Len(CStr(Trim(Fichier))) = 4
Fichier = "*" & Fichier & "*.txt"

If Dir(Chemin & Fichier) = "" Then
MsgBox "Fichier inexistant."
Exit Sub
Else
Workbooks.OpenText Chemin & Fichier
End If







Avatar
Daniel.C
Thisworkbook.close
Daniel
"inès" a écrit dans le message de news:

Bonjour Daniel.C

J'ai une feuille excel (Feuille1) ouverte et la macro m'ouvre un fichier
text.
quand j'utilise la syntax Activeworkbook.close, la feuille excel
(feuille1)
se ferme
mais pas l'application que la macro a ouvert. j'aimerai seulement fermer
l'application.

j'espère que mes explications sont maintenant plus claire.

Louis


Bonjour.
Si j'ai bien compris :
Activeworkbook.close
Cordialement.
Daniel
"inès" a écrit dans le message de news:

Bonjour

La macro ci-dessous me permet d'ouvrire un fichier texte. Comment faire
pour
fermer se fichier automatiquement une fois que les données ont été
récoltées.

mille merci

Inès

Dim NbChar As Integer
Dim Chemin As String
Dim Fichier As Variant

Chemin = "C:Program FilesTMI SoftwareValiVacq 4.3.2"
Do
Fichier = Application.InputBox(Prompt:="dernier 4 chiffres", Type:=2)
If TypeName(Fichier) = "Boolean" Then
MsgBox "opération annulée."
Exit Sub
End If
Loop Until Len(CStr(Trim(Fichier))) = 4
Fichier = "*" & Fichier & "*.txt"

If Dir(Chemin & Fichier) = "" Then
MsgBox "Fichier inexistant."
Exit Sub
Else
Workbooks.OpenText Chemin & Fichier
End If