Wrox Programmer Forums
|
BOOK: Excel 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Excel 2003 VBA Programmer's Reference by Paul T. Kimmel, Stephen Bullen, John Green, Rob Bovey, Robert Rosenberg, Brian Patterson; ISBN: 9780764556609
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Excel 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2008, 12:50 PM
Registered User
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default vba error message

When I run the code below, I got an error message which says "application defined or object defined error "
what is the reason of this error please someone can explain?


Private Sub Import_Click()

Dim UserPath As String
UserPath = Application.GetOpenFilename("Text Files (*.txt), *.txt.", , "Select file to import.", , False)

With Application.ActiveSheet.QueryTables.Add(Connection :=" TEXT; " & UserPath & "" _
, Destination:=Worksheets("Data").Range("A2"))
.Name = "ImportTextFile"

End With
 
Old December 24th, 2008, 02:44 PM
Registered User
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Query Tables in Excel VBA Macro

Mary,

There are two issues here:

First, there are blank spaces before and after the word TEXT. These must be removed. See the line of code below.

With Application.ActiveSheet.QueryTables.Add(Connection :="TEXT;" & UserPath & "" _
, Destination:=Worksheets("Data").Range("A2"))

Second, the worksheet where you create the QueryTable must be the same as the one you use for your destination, otherwise you will get another error.

I hope this helps.

Courtesy of Jack
http://www.Excel-Expert.co.uk

Last edited by ExcelExpert; December 24th, 2008 at 02:46 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the error message for a 500 server error? chobo2 C# 2005 1 May 4th, 2008 03:11 AM
Excel VBA - Send email with html message body elad Excel VBA 1 July 16th, 2007 03:28 PM
error message vubinhsg BOOK: Beginning Access VBA 0 May 21st, 2004 04:10 AM
Error Message Jane SQL Server 2000 3 February 11th, 2004 12:35 PM
??? about error message g_dub96 VB.NET 2002/2003 Basics 0 October 13th, 2003 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.