LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default VBA "1004" error when .Refresh BackgroundQuery:=False

2003/2007

Guess I do not understand what is going on in the background when I
execute the following (intended to process a number of Text files to
import into XL as I get VBA "1004" error when .Refresh
BackgroundQuery:=False :

Sub XLPolySAP()
'
'
Dim myRange As Range
Dim myFileName As String
myFileName = InputBox("Enter file name: ", "File to Process")
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\C lients
\Excel Polymer\SAP Downloads" & myFileName & ".txt",
Destination:=Range("A1"))
'With ActiveSheet.QueryTables.Add(Connection:="TEXT;M:\S AP
Downloads\148530 US31 US32 May 2007.txt", Destination:=Range("A1"))
.Name = myFileName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 9, 1, 9, 1, 9, 1, 9, 1,
9, 1, 9, 1, 9, 1, 9, 3, 9, 1, 9, _
1, 9, 1, 9, 3, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 1, 9, 1, 9, 1,
9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 9)
.TextFileFixedColumnWidths = Array(1, 6, 1, 18, 1, 20, 1, 5,
1, 30, 1, 12, 1, 4, 1, 10, 1, _
10, 1, 8, 1, 10, 1, 4, 1, 10, 1, 4, 1, 13, 1, 10, 1, 10, 1,
10, 1, 10, 1, 10, 1, 10, 1, 12, 1, 12, 1, 4, 1, 17, _
1, 10, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Rows("1:6").Delete
Rows("2:2").Delete
Set myRange = Range(Cells(Cells(Rows.Count, "T").End(xlUp).Row -
2, "A").Address, Cells(Cells(Rows.Count, "T").End(xlUp).Row,
"Z").Address)
'************* Calculates Used Range then Filters out Blank cells
**************
myRange.AutoFilter Field:=1, Criteria1:="<", Operator:=xlAnd
Set myRange = ActiveSheet.Range("A1", Cells(Rows.Count,
"A").End(xlUp))
'************* Deletes Rows with blank cells in Column A
***********************
Application.DisplayAlerts = False
myRange.Delete
Application.DisplayAlerts = True
'Selection.AutoFilter
Range("A1").Select
End Sub


Is the BackgroundQuery saved somewhere?

Also, I intend to use this macro to process a number of files. How
do I get around the error?

TIA Dennis

 
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
problem with "Refresh BackgroundQuery=False" NickHK Excel Programming 0 December 12th 06 03:20 AM
.Refresh BackgroundQuery:=False ikirin[_6_] Excel Programming 0 June 26th 06 04:01 PM
.Refresh BackgroundQuery:=False ikirin[_5_] Excel Programming 0 June 26th 06 03:46 PM
Problems with .Refresh BackgroundQuery:=False dmplacebo Excel Worksheet Functions 0 July 11th 05 12:39 PM
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) Anant[_2_] Excel Programming 1 August 6th 03 04:22 AM


All times are GMT +1. The time now is 12:06 PM.

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

About Us

"It's about Microsoft Excel"