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

Aide sur cette macro

3 réponses
Avatar
Louis
Bonjour

J'ai une macro pour ouvrire un fichier .txt.
Comment faire pour ouvrir la macro seulement en utilisant les derniers 4
chiffres
du non du fichier et surtout de ne pas prendre en compte le texte.

Merci pour l'aide



Public Sub OpenFile()
Dim strText As String
Dim strFile As String

strText = Application.InputBox("dernier 4 chiffres")

strFile = "C:\Program Files\TMI Software\ValiVacq 4.3.2\119452" & _
strText & " inst verpackt kantonsspital nidwalden app 95005v.txt"

If Dir(strFile) = "" Then Exit Sub

Workbooks.OpenText Filename:=strFile _
, Origin:=932, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _
Tab:=True, Semicolon:=False, Comma:=False, Space:=False, _
Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), _
TrailingMinusNumbers:=True
Cells.Select
With selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("C1").Select
Range(selection, selection.End(xlToRight)).Select
Range(selection, selection.End(xlDown)).Select
selection.Copy
Windows("Feuille verticale.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Worksheets("Messwerte Sterilisationzyklus").Activate
Range("A1").Select

End Sub

3 réponses

Avatar
MichDenis
Public Sub OpenFile()
Dim strText As String
Dim strFile As String
Dim Nb as Integer
Dim F as String
Dim A as integer

strText = Application.InputBox("dernier 4 chiffres")

strFile = "C:Program FilesTMI SoftwareValiVacq 4.3.2119452" & _
strText & " inst verpackt kantonsspital nidwalden app 95005v.txt"

nbchar = Len(strfile)
For a = nbchar To 1 Step -1
If IsNumeric(Mid(strfile, a, 1)) Then
f = Mid(strfile, a, 1) & f
If Len(f) = 4 Then
f = "*" & f & "*" & ".xls"
Exit For
End If
End If
Next
If Dir(strFile) = "" Then Exit Sub

Le reste de la macro....



"Louis" a écrit dans le message de news:

Bonjour

J'ai une macro pour ouvrire un fichier .txt.
Comment faire pour ouvrir la macro seulement en utilisant les derniers 4
chiffres
du non du fichier et surtout de ne pas prendre en compte le texte.

Merci pour l'aide



Public Sub OpenFile()
Dim strText As String
Dim strFile As String

strText = Application.InputBox("dernier 4 chiffres")

strFile = "C:Program FilesTMI SoftwareValiVacq 4.3.2119452" & _
strText & " inst verpackt kantonsspital nidwalden app 95005v.txt"

If Dir(strFile) = "" Then Exit Sub

Workbooks.OpenText Filename:=strFile _
, Origin:“2, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:úlse, _
Tab:=True, Semicolon:úlse, Comma:úlse, Space:úlse, _
Other:úlse, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), _
TrailingMinusNumbers:=True
Cells.Select
With selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("C1").Select
Range(selection, selection.End(xlToRight)).Select
Range(selection, selection.End(xlDown)).Select
selection.Copy
Windows("Feuille verticale.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Worksheets("Messwerte Sterilisationzyklus").Activate
Range("A1").Select

End Sub
Avatar
Louis
Bonjour MichDenis

Je me suis surement mal exprimé.
le nom pour ce dossier texte est: 1194529488 inst verpackt kantonsspital
nidwalden app 95005v.txt

Les autre fichiers peuvent comporter un autre chiffre et le texte n'est pas
le même.
donc comment ouvrir le fichier en utilisant seulement les derniers 4 chiffres.

Désolé de d'importuné.

Salutations

Louis






Public Sub OpenFile()
Dim strText As String
Dim strFile As String
Dim Nb as Integer
Dim F as String
Dim A as integer

strText = Application.InputBox("dernier 4 chiffres")

strFile = "C:Program FilesTMI SoftwareValiVacq 4.3.2119452" & _
strText & " inst verpackt kantonsspital nidwalden app 95005v.txt"

nbchar = Len(strfile)
For a = nbchar To 1 Step -1
If IsNumeric(Mid(strfile, a, 1)) Then
f = Mid(strfile, a, 1) & f
If Len(f) = 4 Then
f = "*" & f & "*" & ".xls"
Exit For
End If
End If
Next
If Dir(strFile) = "" Then Exit Sub

Le reste de la macro....



"Louis" a écrit dans le message de news:

Bonjour

J'ai une macro pour ouvrire un fichier .txt.
Comment faire pour ouvrir la macro seulement en utilisant les derniers 4
chiffres
du non du fichier et surtout de ne pas prendre en compte le texte.

Merci pour l'aide



Public Sub OpenFile()
Dim strText As String
Dim strFile As String

strText = Application.InputBox("dernier 4 chiffres")

strFile = "C:Program FilesTMI SoftwareValiVacq 4.3.2119452" & _
strText & " inst verpackt kantonsspital nidwalden app 95005v.txt"

If Dir(strFile) = "" Then Exit Sub

Workbooks.OpenText Filename:=strFile _
, Origin:“2, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:úlse, _
Tab:=True, Semicolon:úlse, Comma:úlse, Space:úlse, _
Other:úlse, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), _
TrailingMinusNumbers:=True
Cells.Select
With selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("C1").Select
Range(selection, selection.End(xlToRight)).Select
Range(selection, selection.End(xlDown)).Select
selection.Copy
Windows("Feuille verticale.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Worksheets("Messwerte Sterilisationzyklus").Activate
Range("A1").Select

End Sub





Avatar
MichDenis
Essaie ceci :


Public Sub OpenFile()
Dim NbChar As Integer
Dim Chemin As String
Dim Fichier As Variant

'le répertoire où sont tes fichiers
Chemin = "C:" ' à définir

Do
Fichier = Application.InputBox(Prompt:="dernier 4 chiffres", Type:=1)
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
' LE RESTE DE TA MACRO....

End Sub



"Louis" a écrit dans le message de news:

Bonjour MichDenis

Je me suis surement mal exprimé.
le nom pour ce dossier texte est: 1194529488 inst verpackt kantonsspital
nidwalden app 95005v.txt

Les autre fichiers peuvent comporter un autre chiffre et le texte n'est pas
le même.
donc comment ouvrir le fichier en utilisant seulement les derniers 4 chiffres.

Désolé de d'importuné.

Salutations

Louis






Public Sub OpenFile()
Dim strText As String
Dim strFile As String
Dim Nb as Integer
Dim F as String
Dim A as integer

strText = Application.InputBox("dernier 4 chiffres")

strFile = "C:Program FilesTMI SoftwareValiVacq 4.3.2119452" & _
strText & " inst verpackt kantonsspital nidwalden app 95005v.txt"

nbchar = Len(strfile)
For a = nbchar To 1 Step -1
If IsNumeric(Mid(strfile, a, 1)) Then
f = Mid(strfile, a, 1) & f
If Len(f) = 4 Then
f = "*" & f & "*" & ".xls"
Exit For
End If
End If
Next
If Dir(strFile) = "" Then Exit Sub

Le reste de la macro....



"Louis" a écrit dans le message de news:

Bonjour

J'ai une macro pour ouvrire un fichier .txt.
Comment faire pour ouvrir la macro seulement en utilisant les derniers 4
chiffres
du non du fichier et surtout de ne pas prendre en compte le texte.

Merci pour l'aide



Public Sub OpenFile()
Dim strText As String
Dim strFile As String

strText = Application.InputBox("dernier 4 chiffres")

strFile = "C:Program FilesTMI SoftwareValiVacq 4.3.2119452" & _
strText & " inst verpackt kantonsspital nidwalden app 95005v.txt"

If Dir(strFile) = "" Then Exit Sub

Workbooks.OpenText Filename:=strFile _
, Origin:“2, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:úlse, _
Tab:=True, Semicolon:úlse, Comma:úlse, Space:úlse, _
Other:úlse, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), _
TrailingMinusNumbers:=True
Cells.Select
With selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("C1").Select
Range(selection, selection.End(xlToRight)).Select
Range(selection, selection.End(xlDown)).Select
selection.Copy
Windows("Feuille verticale.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Worksheets("Messwerte Sterilisationzyklus").Activate
Range("A1").Select

End Sub