Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Excel 2003 and 2000 and VBA Macro

I am sure it will be because QueryTables has more arguments in 2003 than in
2000. Most are defaulted so I would strip them all out

Change

With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & NewFN,
Destination:=Range("B6"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.Refresh BackgroundQuery:=False
End With

to

ActiveSheet.QueryTables.Add(Connection:="TEXT;" & NewFN,
Destination:=Range("B6"))

and see what it complains about on your machine.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Trobert1" wrote in message
...
I have two very quick questions; one that I hope has an easy answer.
Below is some code that I wrote to automate importing a text file in
to Excel. I am using Excel 2003. The people that I am to distribute
this to may or may not have Excel 2003. Some have 2000. My
spreadsheet works on my system, but when I tried it on a system
running 2000 I received errors. Can you tell me what I can do to
correct this? The second question is this: There is a section of my
code that checks to see if the user has cancelled their selection,
but
it gives me a run time error. Have I done something wrong here?

Option Explicit


Private Sub ImportTextFile_Click()
''
'' Code to import txt file for use with the Exceed Exception
Report
'' Written by: Travis Roberts
'' Date: 2/1/08
''
Dim NewFN As String
NewFN = Application.GetOpenFilename(FileFilter:="Test Files (*.txt),
*.txt", Title:="Please select a file")
'If NewFN = False Then
''They pressed Cancel
'MsgBox "Stopping becuase you did not select a file"
'Exit Sub
'End If
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & NewFN,
Destination:=Range("B6"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.Refresh BackgroundQuery:=False
End With
Columns("B:X").EntireColumn.AutoFit
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
Sin Button run macro Excel 2000 - 2003 jfcby[_2_] Excel Programming 1 December 11th 06 02:26 PM
Office 2000 Excel Macro runs very slow in 2003, why? The_Other_Mike Excel Discussion (Misc queries) 1 May 10th 06 04:36 PM
Simple Macro, works in Excel 2002, 2003 but won't work in 2000 DJA[_2_] Excel Programming 5 September 28th 05 05:10 PM
Excel 2000 v 2003 Macro & VBA Incompatibities Wboson Excel Programming 1 March 25th 05 10:40 PM
Excel 2000 v 2003 Macro & VBA Incompatibility Wboson Excel Programming 0 March 25th 05 09:13 PM


All times are GMT +1. The time now is 02:11 AM.

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"