Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default .Refresh BackgroundQuery:=False

Hi,

I get a runtime error 1004 when executing below macro. VBA points to the
..Refresh BackgroundQuery:=False statement. Anybody got a clue what I'm doing
wrong (again)?!

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 24/09/2008 by dresses
'
Fname = Application.GetOpenFilename()
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT; & Fname" _
, Destination:=Range("A3"))
.Name = _

"_pkgcus01_lvs_projs_csm_rep_layout_Sep_23_csm.CRP ST_CSV_910030737_14748.20080923_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False

End With
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default .Refresh BackgroundQuery:=False

You error means that there is something wrong with one of the previous
statments. The query doesn't get execute until the refresh statement so any
thing could be wrong

The line below is wrong. FName is a variable a cannot be inside the double
quote

from
"TEXT; & Fname" _
to
"TEXT;" & Fname _

I cleaned up your code below to make it look better.

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 24/09/2008 by dresses
'
Fname = Application.GetOpenFilename()
'
With ActiveSheet.QueryTables.Add( _
Connection:="TEXT;" & Fname, _
Destination:=Range("A3"))

.Name = "csm_rep_layout_Sep_23"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFileTabDelimiter = True
.TextFileCommaDelimiter = True
.Refresh BackgroundQuery:=False

End With
End Sub"Basta1980" wrote:

Hi,

I get a runtime error 1004 when executing below macro. VBA points to the
.Refresh BackgroundQuery:=False statement. Anybody got a clue what I'm doing
wrong (again)?!

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 24/09/2008 by dresses
'
Fname = Application.GetOpenFilename()
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT; & Fname" _
, Destination:=Range("A3"))
.Name = _

"_pkgcus01_lvs_projs_csm_rep_layout_Sep_23_csm.CRP ST_CSV_910030737_14748.20080923_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False

End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default .Refresh BackgroundQuery:=False

I think that you will need to do something like this:-

Sheets("Data").Select
Range("C7").QueryTable.Refresh BackgroundQuery:=False

Ammend Sheet name & Range to your actual needs

--
Message posted via http://www.officekb.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default .Refresh BackgroundQuery:=False

Hi Joel,

Thank you very much for your help!!!

"Joel" wrote:

You error means that there is something wrong with one of the previous
statments. The query doesn't get execute until the refresh statement so any
thing could be wrong

The line below is wrong. FName is a variable a cannot be inside the double
quote

from
"TEXT; & Fname" _
to
"TEXT;" & Fname _

I cleaned up your code below to make it look better.

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 24/09/2008 by dresses
'
Fname = Application.GetOpenFilename()
'
With ActiveSheet.QueryTables.Add( _
Connection:="TEXT;" & Fname, _
Destination:=Range("A3"))

.Name = "csm_rep_layout_Sep_23"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFileTabDelimiter = True
.TextFileCommaDelimiter = True
.Refresh BackgroundQuery:=False

End With
End Sub"Basta1980" wrote:

Hi,

I get a runtime error 1004 when executing below macro. VBA points to the
.Refresh BackgroundQuery:=False statement. Anybody got a clue what I'm doing
wrong (again)?!

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 24/09/2008 by dresses
'
Fname = Application.GetOpenFilename()
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT; & Fname" _
, Destination:=Range("A3"))
.Name = _

"_pkgcus01_lvs_projs_csm_rep_layout_Sep_23_csm.CRP ST_CSV_910030737_14748.20080923_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False

End With
End Sub

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
.Refresh BackgroundQuery:=False qcan Excel Programming 0 March 10th 08 03:12 PM
.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 01:53 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"