![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to paste a text file to word with vba how to paste with vba or vbscript a text file ( which is actually a director listing: dir a-dir/b) into the new line after the cursor is sitting? or is it possible to use vbscript to add to end of a closed word document the content of a test file? I have the vbscript for creating the desired directory listing in a temporary text file. however I have not figure how to get the context of the into the word document nor clipboard tried IE Dim objIE Set objIE = CreateObject("InternetExplorer.Application") objIE.Navigate(sLstCurrentFn) ' ("about:blank") objIE.document.select() document.parentwindow.copy() ' error below --------------------------- Windows Script Host --------------------------- Script: C:\DOCUME~1\lgary\LOCALS~1\Temp\z.vbs Line: 35 Char: 1 Error: Object doesn't support this property or method: 'document.select' Code: 800A01B6 Source: Microsoft VBScript runtime error --------------------------- OK --------------------------- |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to paste a text file to word with vba ts wrote: Quote: > how to paste with vba or vbscript a text file ( which is actually a director > listing: dir a-dir/b) into the new line after the cursor is sitting? > or is it possible to use vbscript to add to end of a closed word document > the content of a test file? > I have the vbscript for creating the desired directory listing in a > temporary text file. > > however I have not figure how to get the context of the into the word > document nor clipboard > > tried IE > > > Dim objIE > Set objIE = CreateObject("InternetExplorer.Application") > objIE.Navigate(sLstCurrentFn) ' ("about:blank") > objIE.document.select() > document.parentwindow.copy() ' error below > > --------------------------- > Windows Script Host > --------------------------- > Script: C:\DOCUME~1\lgary\LOCALS~1\Temp\z.vbs > Line: 35 > Char: 1 > Error: Object doesn't support this property or method: 'document.select' > Code: 800A01B6 > Source: Microsoft VBScript runtime error > > --------------------------- > OK > --------------------------- > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: how to paste a text file to word with vba ts wrote: Quote: > how to paste with vba or vbscript a text file ( which is actually a director > listing: dir a-dir/b) into the new line after the cursor is sitting? What you are looking for is "insert => file" (look for the "insert" menu item, and the "file... " submenu item. I'm not going to suggest any code, but you can do that for yourself using the "macro recorder". Bring up your document, then turn on the macro recorder. Go through the operations you want to record, such as inserting your text file into your document, then turn off the recorder. What you get is a "macro" recorded in the vba language. You can use it in msWord as is, _or_ you can do the entire thing via script. You instantiate msWord ("Word.Application"), open your file, and then "convert your vba macro to script", to get your text file inserted into the word document. (note: converting the macro is pretty easy, with only a couple of "gotchas" -- which can ge easily found by (adv) googling this ng). cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) --- <boilerplate: using macro recorder to script msWD/XL> --- I don't have any scripts handy, but my standard advice for a situation like this is to turn on your excel macro recorder, go through the operation you want to do "manually" (say, for the first two worksheets), then turn off the macro recorder. Go to the editor for macros, and pick out the vba macro code. You then convert the vba to vbs -- not too hard to do -- but there are a couple of things to watch out for. The most common "thing to watch out for" is named arguments to functions or subs. You are going to have to enter the argument values (without the names) in their proper order. A more definitive statement of "things to watch out for" (when converting vba to vbs) may be found in the ng archives. Go to: http://groups.google.com/advanced_group_search Also, there are many postings about using excel's automation interface, and converting vba to vbs in this very newsgroup, which can also be located using google's group search. --- <end of macro recorder boilerplate> --- |
My System Specs![]() |
| | #4 (permalink) |
| | sorry about that... mr_unreliable wrote: Quote: > > mr_unreliable clicked the wrong button, sorry. |
My System Specs![]() |
| | #5 (permalink) |
| 64 | Re: how to paste a text file to word with vba Dear Sir, I have the same problem as you in my profession I use text files and the data and writes to word inserting text and images. Below you will find 2 links to my badly styled home page that I have for fun. There are two macro codes one for extracting data from one text file and one program that lists all files in a directory combined you can extract data from muliple text files. Code for writing to word I have not added yet but will do so within a few hours hopefully!!! Enjoy http://vbaexcel.eu/vba-macro-code/list-files-in-directory Read Text File Fetch Data vba-macro-code how to paste with vba or vbscript a text file ( which is actually a director listing: dir a-dir/b) into the new line after the cursor is sitting? or is it possible to use vbscript to add to end of a closed word document the content of a test file? I have the vbscript for creating the desired directory listing in a temporary text file. however I have not figure how to get the context of the into the word document nor clipboard tried IE Dim objIE Set objIE = CreateObject("InternetExplorer.Application") objIE.Navigate(sLstCurrentFn) ' ("about:blank") objIE.document.select() document.parentwindow.copy() ' error below --------------------------- Windows Script Host --------------------------- Script: C:\DOCUME~1\lgary\LOCALS~1\Temp\z.vbs Line: 35 Char: 1 Error: Object doesn't support this property or method: 'document.select' Code: 800A01B6 Source: Microsoft VBScript runtime error --------------------------- OK --------------------------- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Unable to paste from web to word | Microsoft Office | |||
| HELP! Can't paste links or text from internet | Browsers & Mail | |||
| text paste not working in command window | Vista General | |||
| Copy / Paste from Word | Vista General | |||
| How do you copy and paste text in Vista?? | Vista General | |||