How to fetch data from notepad in VB6?

5 pts.
Tags:
Data
Notepad
VB
Visual Basic
Visual Basic 6
I just want to know if there are ways to retrieve data from notepad and use it in my VB6 program.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I don’t know if VBA has specific hooks for Notepad, but Notepad docs are just plain text, which is fairly easy to retrieve in VBA. Microsoft has a page on using FileSystemObject to open text files that contains instructions and sample code that will probably set you on your path. HTH.

Hi Morfs,
Same as Yuval I don’t know if Notepad exports an object model. May be you can find it in the references of your VB environment, together with ADO and the like.
But if you know the name of the file being edited then you can use the VB “sendkeys” command to make Notepad select all the text and copy it in the clipboard, for example.
To do sendkeys you typically need to know the text in the window’s bar, for example “thefile.txt – Notepad” (open a fil ein Notepad and take note of the content in the title bar).
Notice that the keys you send to the program are language-dependent. For example to select the complete content in an English Windows the command is control-a and in Spanish it’s control-e.
Also note that there could be more than one window with the same title.
Moreover, remember thet VB has a control, a rich text editor, with more or less the same functionality as Notemap, and depending on your app you might host the text edition instead of spawning a Notepad. It it opens bacause the user double-clicks a spacial file type then associate that file type so it will open your app.

Juan Lanus

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • arkajagar

    I would like to import whole data from "wordpad" files to excel.

    I can able to open my file in wordpad but unable to copy & paste in the required excel sheet.

    Please help me.

    10 pointsBadges:
    report
  • ToddN2000
    Are you trying to copy and paste it into one cell? That kind of defeats the purpose of putting it in a spreadsheet. Save your document as a plain text file. You are better off opening the .TXT file in Excel and setting your delimiters or columns to break the text data up.
    43,965 pointsBadges:
    report
  • TheRealRaven
    Neither Wordpad nor Notepad support Automation, OLE, DDE, etc. These are very simple programs without added stuff for communication/linkage. If you need the extra stuff, use more advanced programs.

    I don't know if VB can easily link to various Windows APIs as easily as C# can. If it can, there are APIs to get handles for any open windows. Once handles are known, it's possible to send any keys to the windows. So copy/paste would be possible.
    18,995 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: