Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 6th, 2005, 03:25 AM
Registered User
Join Date: Jul 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Apply Custom template & import data from text file

Following is a code piece to apply custom template to Excel.
Dim exlApp As New Excel.Application
Dim exlWB As New Excel.Workbook
Dim s As Excel.XlWBATemplate
Dim exlWSht As Excel.Worksheet
Set exlWB=exlApp.Workbooks.Add "C:\...\Microsoft\Templates\Tplt1.xlt")

I have a text file. How can I write this further for importing the text file into Excel Worbook with my template? I tried using as below but in vain :
Set exlWB = exlApp.Workbooks.Open "C:\Sheet.txt")

I am able to open either a data sheet or an empty template sheet but not data on template..Can somebody help? Thanks .

Reply With Quote
  #2 (permalink)  
Old August 8th, 2005, 07:39 AM
Authorized User
Join Date: Feb 2005
Location: , , Netherlands.
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts

What I used to do is the following:

Run a macro, and do the following:

1) Goto Data> Import External Data > Import data
2) Browse for your text file and select open
3) Go through the wizard and select finish

You now have your textfile imported into cells. I am not sure this works with every version of Excel, but I think its Excel 9.0 and higher

Hope this helps
Reply With Quote
  #3 (permalink)  
Old August 8th, 2005, 07:41 AM
Authorized User
Join Date: Feb 2005
Location: , , Netherlands.
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts

A short note:

The data is stored into lots of cells, but you can choose the upper-left cell. You do this just by selecting a cell you want to be the upper-left one, and then run the wizard (and naturally, first hit the "record macro" button before doing anything ..)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
call template from diff file? (import vs. include) mister_mister XSLT 5 January 31st, 2007 07:12 PM
Text file importing & data processing jarpola Excel VBA 0 January 16th, 2007 10:27 AM
How to import data from text file? starnet SQL Server 2000 1 September 18th, 2006 06:56 AM
Text file import to data grid missing some values kf9thdon@aol.com ASP.NET 1.0 and 1.1 Basics 2 April 14th, 2006 10:42 AM
import data from text file to excel(VBA) topr Excel VBA 2 August 26th, 2004 11:36 PM

All times are GMT -4. The time now is 04:29 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.