#1
|
|||
|
|||
Open txt file with macro
Hello everybody
I have this code that gives me error .... instruction in red, it should open a dialog box to choose a txt file. [SIZE="2"]Private Sub CommandButton3_Click() filetoOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") Workbooks.OpenText Filename:= filetoOpen , Origin:=xlWindows, 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), Array(7, 1)), _ TrailingMinusNumbers:=True End Sub[/SIZE] |
#2
|
|||
|
|||
Code:
Option Explicit Sub whatFile() Dim filetoOpen As String filetoOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") Workbooks.OpenText Filename:=filetoOpen, Origin:=xlWindows, 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), Array(7, 1)), _ TrailingMinusNumbers:=True End Sub |
#3
|
|||
|
|||
Many thanks !!!!
|
#4
|
|||
|
|||
You are welcome.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro now requires file extension entered to open document | Rampum15 | Word VBA | 2 | 12-09-2019 06:19 AM |
Every Folder I open goes into File Explorer but when I click on a file it won't open | bird dog | Word | 3 | 10-08-2019 10:03 AM |
Macro to open Multiple files and copy information to a master file | gbaker | Excel Programming | 2 | 04-08-2016 08:44 AM |
Formula to open external file with specific program (like open with) | pemartins | Excel | 16 | 02-24-2014 11:39 PM |
excel cannot open the file .xlsx because the file format or file extension is not val | teddysika | Excel | 1 | 11-22-2012 06:06 AM |