Hi all,
Please help I am currently stuck.
My problem is to write a macro that will copy a range of cells like (B2: B15), auto open and paste the data to a word processor like notepad or MS word without the gridlines.
Hi all,
Please help I am currently stuck.
My problem is to write a macro that will copy a range of cells like (B2: B15), auto open and paste the data to a word processor like notepad or MS word without the gridlines.
You cannot automate Notepad. You have two options to go directly to a text file automatically:
1. use Excel VBA to launch Notepad, then use SendKeys command to paste
2. use Excel VBA and the TextStream Object to output directly to a text file
I greatly recommend option 2 over option 1. In VB Editor, do a search on the text stream object. The example code (shown below) is exactly what you need.
Another option would be to automate Word. This is similar to Option 2 above. It is a bit more complicated, though, since Word has so many more options than a simple text file.Please Login or Register to view this content.
Thanks MSP77079
The code works but how do I make the writeline syntax copy my range of excell data to the textfile.txt.
Please help.
Hi,
I would wait for MSP77079 reply as my way you'll need to set a reference to the Microsoft Scripting RunTime Library.
If you do want to try this then In the VBA editor, go to Tools, References, and find and check this library. Then, you can use code such as the following:
Please Login or Register to view this content.
VBA Noob
_________________________________________
Credo Elvem ipsum etian vivere
_________________________________________
A message for cross posters
Please remember to wrap code.
Forum Rules
Please add to your signature if you found this link helpful. Excel links !!!
Emmamaki, the difference between what the Noob suggest and what I suggest is minor (and perhaps esoteric); namely, early vs. late binding of an object.
Below I have taken Noob's code and shown with comments what the difference is:
Please Login or Register to view this content.
Last edited by MSP77079; 01-06-2007 at 12:25 PM.
Nice one MSP77079.
VBA Noob
Thanks MSP77079 and VBA Noob
The code works perfect.
I must confess this forum is the best in the whole wide world.
Keep it up people.
Thanks once again.
Glad you found a answer
VBA Noob
hi... i think this is what I've been looking for a very long time..
can I see the result? I'm looking for a macro wherein I will enter the data like a form type, after filling all the information I will click on copy button to copy all those data I entered so that when I go to my notepad and paste it will paste all the data in a nice format. is that possible? or is this macro like what I'm looking for? please help..
Hi i want to write data of each cell and row into another notepad using macro please help asap.....
bilal.ahmed,
Welcome to the Forum, unfortunately:
Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks