Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Paste Data To WordPad TXT File

I have a fairly simple macro that copies data from a few sheets and
consolidates it (via paste) into one sheet. I know what to copy this
consoldiates data in this sheet (say A1:G65) and I want to copy it and paste
it into a wordpad document file (NewData.txt) and save the txt file once it
is pasted so i can then do some different work with the txt file.

How do i call these tasks from within an excel macro?

thx
davem
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Paste Data To WordPad TXT File

You can't automate WordPad or NotePad, unless you use the dreaded SendKeys
method. It would be much easier to use VB's own file input/output functions
to write the text file. Something along the lines of

Sub WriteToTextFile()
Dim FName As Variant
Dim FNum As Integer
Dim R As Range

FName = Application.GetSaveAsFilename(filefilter:="Text Files
(*.txt),*.txt")
If FName = False Then
' user cancelled
Exit Sub
End If

FNum = FreeFile()
Open FName For Output Access Write As #FNum
For Each R In Range("A1:A10")
Print #FNum, R.Text
Next R
Close #FNum
End Sub

See also www.cpearson.com/Excel/ImpText.aspx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)





"DaveM" wrote in message
...
I have a fairly simple macro that copies data from a few sheets and
consolidates it (via paste) into one sheet. I know what to copy this
consoldiates data in this sheet (say A1:G65) and I want to copy it and
paste
it into a wordpad document file (NewData.txt) and save the txt file once
it
is pasted so i can then do some different work with the txt file.

How do i call these tasks from within an excel macro?

thx
davem


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
connecting wordpad and excel Jan Excel Discussion (Misc queries) 1 May 4th 07 01:37 PM
WordPad file convert in Excel Tarique Excel Discussion (Misc queries) 1 April 21st 06 02:48 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
i try to open Excel spreadsheets, and they open in wordpad-- mikekeat Excel Discussion (Misc queries) 2 October 1st 05 10:13 PM
When sending file via email, cannot paste Excel data into body of letter. Pierre Excel Discussion (Misc queries) 2 February 23rd 05 09:27 PM


All times are GMT +1. The time now is 09:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"