Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Matt7102
 
Posts: n/a
Default Macro Issue - Run time error 1004

My VBA skills are limited to using recorded macros, not writing them- so when
something won't execute... well, I'm lost.

I painstakingly recorded my actions importing 38 small text files, including
a clear contents command so that the workbook can be re-used. I have done
this successfully in the past. The macro worked after creation once, but not
after a save/close workbook. It now stalls at ' .Refresh
BackgroundQuery:=False' of the first import as displayed below, with 'run
time error 1004 - Application Defined or object - defined error

Sub DataImport()
'
' DataImport Macro
' Clear Old Data, Import New Data
'

'
Sheets("ChevyL").Select
Rows("10:55").Select
Selection.ClearContents
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;\\addc01\TS My Documents\gcomproom\output\PGPCB01.999",
Destination:= _
Range("A10"))
.Name = "PGPCB01"
.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(1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(5, 21, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("ChevyT").Select
Rows("10:55").Select
Selection.ClearContents
With ActiveSheet.QueryTables.Add(Connection:= _

.....and the process continues for 37 additional files.

Anyone have a quick fix?

TIA,

matt7102
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Cone
 
Posts: n/a
Default Macro Issue - Run time error 1004

M,

My knowledge in this area is pretty limited, however I would try
commenting out the offending line and seeing if the code will run...
' .Refresh BackgroundQuery:=False

Jim Cone
San Francisco, USA
Free add-ins at my website ...
http://www.realezsites.com/bus/primitivesoftware



"Matt7102"
wrote in message
...
My VBA skills are limited to using recorded macros, not writing them- so when
something won't execute... well, I'm lost.
I painstakingly recorded my actions importing 38 small text files, including
a clear contents command so that the workbook can be re-used. I have done
this successfully in the past. The macro worked after creation once, but not
after a save/close workbook. It now stalls at ' .Refresh
BackgroundQuery:=False' of the first import as displayed below, with 'run
time error 1004 - Application Defined or object - defined error

Sub DataImport()
'
' DataImport Macro
' Clear Old Data, Import New Data
'

'
Sheets("ChevyL").Select
Rows("10:55").Select
Selection.ClearContents
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;\\addc01\TS My Documents\gcomproom\output\PGPCB01.999",
Destination:= _
Range("A10"))
.Name = "PGPCB01"
.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(1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(5, 21, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("ChevyT").Select
Rows("10:55").Select
Selection.ClearContents
With ActiveSheet.QueryTables.Add(Connection:= _

.....and the process continues for 37 additional files.
Anyone have a quick fix?
TIA,
matt7102
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
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
Excel Time Manipulation BFiedler Excel Discussion (Misc queries) 0 September 15th 05 01:15 AM
conditional formatting with time values Access Idiot Excel Discussion (Misc queries) 2 September 13th 05 03:29 PM
Can I get a macro to run at a certain time of day? Nick123 Excel Discussion (Misc queries) 2 July 27th 05 11:31 AM
Date and Time Macro m.j.anderson Excel Discussion (Misc queries) 1 December 1st 04 12:35 AM


All times are GMT +1. The time now is 08:59 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"