LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default import external data via macro/vba question

Drabbacs

1) How should the .CommandText = Array() phrase look when
using a dynamic filename?


I rarely use Array(). You need it if your SQL string is more than 255
characters, but only in certain circumstances. In your case, just use

..CommandText = Filename1 & "$"

It would probably work with

..CommandText = Array(Filename1 & "$")

but you really don't need it.


2) In general when dealing with multiple files in a macro,
how do you keep track and switch focus between them?


Switch focus - you don't. There should be no need to switch the focus of
the workbooks except at the very end of your macro (to make sure the one you
want the user to see is active). Otherwise, I use object variables

Dim wbStart as Workbook
Dim wbText as Workbook

Set wbStart = ActiveWorkbook

Set wbText = Workbooks.OpenText (...)

Then you can use wbStart and wbText to refer to whichever one you need.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


 
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
Import External Data Bongard Excel Discussion (Misc queries) 3 January 8th 10 06:59 PM
External data import B Cut Excel Discussion (Misc queries) 0 October 16th 09 07:11 PM
import external data Swan0tree Excel Discussion (Misc queries) 2 October 1st 09 10:19 PM
Import External Data RFJ Excel Discussion (Misc queries) 1 August 28th 06 12:16 AM
Import External Data - XML mklapp Excel Discussion (Misc queries) 0 October 26th 05 07:04 PM


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