Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default GetOpenFilename

1. I am able to use Getopenfilename to allow the user to select a file to open.

a.. fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If


2. What I would really like to do is allow the user to select the file (a TXT file), but then get the same macro to apply predefined settings to the "Text Import wizard" i.e what the data type is, what the delimiter is and what the Column data format is. I have recorded the macro to open a file with the required settings, but the recorded macro obviously specifies the file name used in the recording. The macro line also seems to be one continuous line. How do I split it into 2 lines, one for filename and one for settings?

Any help would be greatly appreciated.

Thanks in advance

Craig
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default GetOpenFilename

Change the name in the recorded macro to fileToOpen.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Craig" wrote in message
...
1. I am able to use Getopenfilename to allow the user to select a file
to open.

a.. fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If


2. What I would really like to do is allow the user to select the file (a
TXT file), but then get the same macro to apply predefined settings to the
"Text Import wizard" i.e what the data type is, what the delimiter is and
what the Column data format is. I have recorded the macro to open a file
with the required settings, but the recorded macro obviously specifies the
file name used in the recording. The macro line also seems to be one
continuous line. How do I split it into 2 lines, one for filename and one
for settings?

Any help would be greatly appreciated.

Thanks in advance

Craig


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default GetOpenFilename

Thanks Bob, but I don't know how to do that.

My macro is as follows:

Workbooks.OpenText fileName:="C:\spirit.txt", Origin:=437, _
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,
2), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14,
1), Array(15, 1), Array( _
16, 2), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1),
Array(21, 1), Array(22, 1), _
Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27,
1), Array(28, 1), Array( _
29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1),
Array(34, 1), Array(35, 1), _
Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1)),
TrailingMinusNumbers:=True
End Sub

Craig

"Bob Phillips" wrote in message
...
Change the name in the recorded macro to fileToOpen.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Craig" wrote in message
...
1. I am able to use Getopenfilename to allow the user to select a file
to open.

a.. fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If


2. What I would really like to do is allow the user to select the file

(a
TXT file), but then get the same macro to apply predefined settings to the
"Text Import wizard" i.e what the data type is, what the delimiter is and
what the Column data format is. I have recorded the macro to open a file
with the required settings, but the recorded macro obviously specifies the
file name used in the recording. The macro line also seems to be one
continuous line. How do I split it into 2 lines, one for filename and one
for settings?

Any help would be greatly appreciated.

Thanks in advance

Craig




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default GetOpenFilename

Like this, after the GetOpenFilename

Workbooks.OpenText Filename:=filetoopen, _
Origin:=437, _
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, 2), Array(3, 1), _
Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12,
1), _
Array(13, 1), Array(14, 1), Array(15,
1), _
Array(16, 2), Array(17, 1), Array(18,
1), _
Array(19, 1), Array(20, 1), Array(21,
1), _
Array(22, 1), Array(23, 1), Array(24,
1), _
Array(25, 1), Array(26, 1), Array(27,
1), _
Array(28, 1), Array(29, 1), Array(30,
1), _
Array(31, 1), Array(32, 1), Array(33,
1), _
Array(34, 1), Array(35, 1), Array(36,
1), _
Array(37, 1), Array(38, 1), Array(39,
1)), _
TrailingMinusNumbers:=True


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Craig" wrote in message
...
Thanks Bob, but I don't know how to do that.

My macro is as follows:

Workbooks.OpenText fileName:="C:\spirit.txt", Origin:=437, _
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,
2), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14,
1), Array(15, 1), Array( _
16, 2), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1),
Array(21, 1), Array(22, 1), _
Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27,
1), Array(28, 1), Array( _
29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1),
Array(34, 1), Array(35, 1), _
Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1)),
TrailingMinusNumbers:=True
End Sub

Craig

"Bob Phillips" wrote in message
...
Change the name in the recorded macro to fileToOpen.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Craig" wrote in message
...
1. I am able to use Getopenfilename to allow the user to select a

file
to open.

a.. fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If


2. What I would really like to do is allow the user to select the

file
(a
TXT file), but then get the same macro to apply predefined settings to

the
"Text Import wizard" i.e what the data type is, what the delimiter is

and
what the Column data format is. I have recorded the macro to open a file
with the required settings, but the recorded macro obviously specifies

the
file name used in the recording. The macro line also seems to be one
continuous line. How do I split it into 2 lines, one for filename and

one
for settings?

Any help would be greatly appreciated.

Thanks in advance

Craig






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default GetOpenFilename

Bob,

That's great!

Thanks.

Craig

"Bob Phillips" wrote in message
...
Like this, after the GetOpenFilename

Workbooks.OpenText Filename:=filetoopen, _
Origin:=437, _
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, 2), Array(3, 1),
_
Array(4, 1), Array(5, 1), Array(6, 1),
_
Array(7, 1), Array(8, 1), Array(9, 1),
_
Array(10, 1), Array(11, 1), Array(12,
1), _
Array(13, 1), Array(14, 1), Array(15,
1), _
Array(16, 2), Array(17, 1), Array(18,
1), _
Array(19, 1), Array(20, 1), Array(21,
1), _
Array(22, 1), Array(23, 1), Array(24,
1), _
Array(25, 1), Array(26, 1), Array(27,
1), _
Array(28, 1), Array(29, 1), Array(30,
1), _
Array(31, 1), Array(32, 1), Array(33,
1), _
Array(34, 1), Array(35, 1), Array(36,
1), _
Array(37, 1), Array(38, 1), Array(39,
1)), _
TrailingMinusNumbers:=True


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Craig" wrote in message
...
Thanks Bob, but I don't know how to do that.

My macro is as follows:

Workbooks.OpenText fileName:="C:\spirit.txt", Origin:=437, _
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,
2), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14,
1), Array(15, 1), Array( _
16, 2), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1),
Array(21, 1), Array(22, 1), _
Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27,
1), Array(28, 1), Array( _
29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array(33, 1),
Array(34, 1), Array(35, 1), _
Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1)),
TrailingMinusNumbers:=True
End Sub

Craig

"Bob Phillips" wrote in message
...
Change the name in the recorded macro to fileToOpen.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Craig" wrote in message
...
1. I am able to use Getopenfilename to allow the user to select a

file
to open.

a.. fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If


2. What I would really like to do is allow the user to select the

file
(a
TXT file), but then get the same macro to apply predefined settings to

the
"Text Import wizard" i.e what the data type is, what the delimiter is

and
what the Column data format is. I have recorded the macro to open a
file
with the required settings, but the recorded macro obviously specifies

the
file name used in the recording. The macro line also seems to be one
continuous line. How do I split it into 2 lines, one for filename and

one
for settings?

Any help would be greatly appreciated.

Thanks in advance

Craig








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GetOpenFileName with F*.txt DRK Excel Programming 6 June 7th 05 12:45 PM
GetOpenFileName help Leith Ross[_12_] Excel Programming 0 April 8th 05 10:14 PM
GetOpenFilename Chodu Excel Programming 1 May 17th 04 06:17 PM
GetOpenFileName Greg Bloom Excel Programming 2 February 9th 04 04:09 PM
getopenfilename inquirer Excel Programming 1 December 3rd 03 11:37 AM


All times are GMT +1. The time now is 04:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"