Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| 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 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
  #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 .

  #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
Default

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
Max
  #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
Default

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 ..)


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





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