Hi,
as an nonprogrammer I recorded macro to import file from fixed position:
Sub import()
ChDir "D:\import"
Workbooks.OpenText Filename:="D:\import\OFFLINE.DAT", Origin:= _
852, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1)), DecimalSeparator:=".", TrailingMinusNumbers _
:=False
End Sub
even worse, I found (in WBA Help) how to show file path,
Sub Main()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
.Filters.Clear
.Filters.Add "All files", "*.*"
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
MsgBox "Path name: " & vrtSelectedItem
Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With
Set fd = Nothing
End Sub
but I dont know how to import selected file from Main() with all settings from Import() macro.
I have read posts both from VRoscioli and Fumei, I have tried to play arround a little, but it does not work. (Obviously, Iam not a golfer)
It is a "piece of cake" thing, but I have no experience in VBA.
Many Thanks
Seta42
as an nonprogrammer I recorded macro to import file from fixed position:
Sub import()
ChDir "D:\import"
Workbooks.OpenText Filename:="D:\import\OFFLINE.DAT", Origin:= _
852, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1)), DecimalSeparator:=".", TrailingMinusNumbers _
:=False
End Sub
even worse, I found (in WBA Help) how to show file path,
Sub Main()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With fd
.Filters.Clear
.Filters.Add "All files", "*.*"
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
MsgBox "Path name: " & vrtSelectedItem
Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With
Set fd = Nothing
End Sub
but I dont know how to import selected file from Main() with all settings from Import() macro.
I have read posts both from VRoscioli and Fumei, I have tried to play arround a little, but it does not work. (Obviously, Iam not a golfer)
It is a "piece of cake" thing, but I have no experience in VBA.
Many Thanks
Seta42