Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / December 2007

Tip: Looking for answers? Try searching our database.

Paste Data To WordPad TXT File

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaveM - 26 Dec 2007 19:12 GMT
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
Chip Pearson - 26 Dec 2007 20:19 GMT
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

Signature

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

>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
[quoted text clipped - 8 lines]
> thx
> davem
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.