Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I grab a certain file line and input to another file?

Status
Not open for further replies.

JasonLiew

Programmer
Joined
Oct 15, 2001
Messages
37
Location
SG
I've successfully input words from VB into words document(DCR.doc). The problem is, how do I grab these words i've input into the words document(DCR.doc) and put em' into another words document(Amend.doc) using VB code? Please help. Thanks in advance.

With Regards,
Jason
 
Are you trying to copy the DCR.doc file to Amend.doc (erasing what was previously in it), or is DCR.doc a new file, and you are trying to append the new text to what was already in Amend.doc? "The night sky over the planet Krikkit is the least interesting sight in the entire universe."

-Hitch Hiker's Guide To The Galaxy
 
I am trying to copy whats inside DCR.doc and paste them into a new document named Admend.doc. And how do i know that a particular document has reached its end with words and then open up another same word documents?
 
Sorry for the delayed response...

If you're trying to copy an existing document, and create a new document from the existing one (with all of the same contents) from VB, try using the CopyFile API. Put this code into your module:

Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long

And reference it from anywhere that you'd like (command button, form load, etc.), assuming that your file is on your C drive, like so:

CopyFile "C:\DCR.doc", "C:\Amend.doc", FALSE

This will create an exact duplicate of DCR.doc as Amend.doc. The FALSE statement at the end of the function overwrites any previously existing document named Amend.doc. If you don't want the file overwritten, simply change FALSE to TRUE. Hope this helps you. "The night sky over the planet Krikkit is the least interesting sight in the entire universe."

-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top