Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Skipping Import Text File dialog in a Macro

I tried the following but the dialog always appears and forces me to click
the Import button.

Sheets("Sheet1").Select
Application.DisplayAlerts = False
With Selection.QueryTable
.Connection = _
"TEXT;C:\Edrive\standalone\Lineup\18ScorecardRoste r.txt"
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2)
.TextFileFixedColumnWidths = Array(4)
.Refresh BackgroundQuery:=False
End With
Sheets("Scorecard-v").Select

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Skipping Import Text File dialog in a Macro

I'm not usre, but I think it is because you are using Fix Width data. I
don't get the pop up when I'm using Delimited Data. try re-recording a macro
and use a Delimiter rather than fixed width. If you need fixed width data
then I have a macro that opens a text file and export the cells one at a time.

"Leon" wrote:

I tried the following but the dialog always appears and forces me to click
the Import button.

Sheets("Sheet1").Select
Application.DisplayAlerts = False
With Selection.QueryTable
.Connection = _
"TEXT;C:\Edrive\standalone\Lineup\18ScorecardRoste r.txt"
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2)
.TextFileFixedColumnWidths = Array(4)
.Refresh BackgroundQuery:=False
End With
Sheets("Scorecard-v").Select

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Skipping Import Text File dialog in a Macro

Thanks Joel, you were right. Could you help me with one other thing (I am
very new at this)? How can I clear the "save" flag so exiting won't prompt
the user to save?

"Joel" wrote:

I'm not usre, but I think it is because you are using Fix Width data. I
don't get the pop up when I'm using Delimited Data. try re-recording a macro
and use a Delimiter rather than fixed width. If you need fixed width data
then I have a macro that opens a text file and export the cells one at a time.

"Leon" wrote:

I tried the following but the dialog always appears and forces me to click
the Import button.

Sheets("Sheet1").Select
Application.DisplayAlerts = False
With Selection.QueryTable
.Connection = _
"TEXT;C:\Edrive\standalone\Lineup\18ScorecardRoste r.txt"
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2)
.TextFileFixedColumnWidths = Array(4)
.Refresh BackgroundQuery:=False
End With
Sheets("Scorecard-v").Select

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Skipping Import Text File dialog in a Macro

I don't think you can turn off the save flag when exiting excel. You can in
a macro
make the savechanges either true or false. False will eliminate the prompt.

Workbooks("BOOK1.XLS").Close SaveChanges:=False


"Leon" wrote:

Thanks Joel, you were right. Could you help me with one other thing (I am
very new at this)? How can I clear the "save" flag so exiting won't prompt
the user to save?

"Joel" wrote:

I'm not usre, but I think it is because you are using Fix Width data. I
don't get the pop up when I'm using Delimited Data. try re-recording a macro
and use a Delimiter rather than fixed width. If you need fixed width data
then I have a macro that opens a text file and export the cells one at a time.

"Leon" wrote:

I tried the following but the dialog always appears and forces me to click
the Import button.

Sheets("Sheet1").Select
Application.DisplayAlerts = False
With Selection.QueryTable
.Connection = _
"TEXT;C:\Edrive\standalone\Lineup\18ScorecardRoste r.txt"
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2)
.TextFileFixedColumnWidths = Array(4)
.Refresh BackgroundQuery:=False
End With
Sheets("Scorecard-v").Select

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Skipping Import Text File dialog in a Macro

How can I convert the fixed string file path to a variable? I tried the
following:
Dim fileDir As String
fileDir = ThisWorkbook.Path
Dim fileName As String
fileName = fileDir & "\Release\18ScorecardRoster.txt"
Sheets("Sheet1").Select
With Selection.QueryTable
.Connection = _
"TEXT;fileName"


"Joel" wrote:

I don't think you can turn off the save flag when exiting excel. You can in
a macro
make the savechanges either true or false. False will eliminate the prompt.

Workbooks("BOOK1.XLS").Close SaveChanges:=False


"Leon" wrote:

Thanks Joel, you were right. Could you help me with one other thing (I am
very new at this)? How can I clear the "save" flag so exiting won't prompt
the user to save?

"Joel" wrote:

I'm not usre, but I think it is because you are using Fix Width data. I
don't get the pop up when I'm using Delimited Data. try re-recording a macro
and use a Delimiter rather than fixed width. If you need fixed width data
then I have a macro that opens a text file and export the cells one at a time.

"Leon" wrote:

I tried the following but the dialog always appears and forces me to click
the Import button.

Sheets("Sheet1").Select
Application.DisplayAlerts = False
With Selection.QueryTable
.Connection = _
"TEXT;C:\Edrive\standalone\Lineup\18ScorecardRoste r.txt"
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2)
.TextFileFixedColumnWidths = Array(4)
.Refresh BackgroundQuery:=False
End With
Sheets("Scorecard-v").Select



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Skipping Import Text File dialog in a Macro

whan combining strings you must use the & character


Dim fileDir As String
fileDir = ThisWorkbook.Path
Dim fileName As String
fileName = fileDir & "\Release\18ScorecardRoster.txt"
Sheets("Sheet1").Select
With Selection.QueryTable
.Connection = _
"TEXT;" & fileName

"Leon" wrote:

How can I convert the fixed string file path to a variable? I tried the
following:
Dim fileDir As String
fileDir = ThisWorkbook.Path
Dim fileName As String
fileName = fileDir & "\Release\18ScorecardRoster.txt"
Sheets("Sheet1").Select
With Selection.QueryTable
.Connection = _
"TEXT;fileName"


"Joel" wrote:

I don't think you can turn off the save flag when exiting excel. You can in
a macro
make the savechanges either true or false. False will eliminate the prompt.

Workbooks("BOOK1.XLS").Close SaveChanges:=False


"Leon" wrote:

Thanks Joel, you were right. Could you help me with one other thing (I am
very new at this)? How can I clear the "save" flag so exiting won't prompt
the user to save?

"Joel" wrote:

I'm not usre, but I think it is because you are using Fix Width data. I
don't get the pop up when I'm using Delimited Data. try re-recording a macro
and use a Delimiter rather than fixed width. If you need fixed width data
then I have a macro that opens a text file and export the cells one at a time.

"Leon" wrote:

I tried the following but the dialog always appears and forces me to click
the Import button.

Sheets("Sheet1").Select
Application.DisplayAlerts = False
With Selection.QueryTable
.Connection = _
"TEXT;C:\Edrive\standalone\Lineup\18ScorecardRoste r.txt"
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2)
.TextFileFixedColumnWidths = Array(4)
.Refresh BackgroundQuery:=False
End With
Sheets("Scorecard-v").Select

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
How to import text file into one column Jeff[_4_] Excel Discussion (Misc queries) 4 October 20th 07 03:15 PM
import from text file jason2444 Excel Discussion (Misc queries) 2 January 17th 07 04:22 PM
Macro to Import Text Miasha Excel Discussion (Misc queries) 8 August 18th 06 04:30 PM
Would Like to Automate Batch File Creation and Text FIle Import socrtwo Excel Discussion (Misc queries) 2 August 18th 06 03:54 PM
Import text file to a SINGLE ROW? robazefa Excel Discussion (Misc queries) 1 November 2nd 05 05:05 AM


All times are GMT +1. The time now is 09:10 AM.

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"