How to load a string into the default text editor

I'l like to load a string straight into the users default text editor (or if necessary notepad)

I can do this by saving as a file but I'd like to by pass this and put the string straight into the users default editor.
They can then choose whether to save the file.
colindowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

craigewensCommented:
I'm not entirely sure what you mean, but would putting something into the users clipboard be acceptable?

[code]
    Clipboard.Clear
    Clipboard.SetText "Default text would go in here."
[/code]

Your users then just need to paste this anywhere they wish.
0
colindowAuthor Commented:
As it happens this is what I'm doing at the moment. What I would like to do is present them with the default text editor with the text loaded.

I do something similar where I create an instance of excel to give the user results. If they save the file they have a copy. If they don't there is nothing left on their disk.

In this case I need to work out the app to use (i.e. the defualt text editor) then apply the text string to an empty document.
0
craigewensCommented:
The registry entry [HKEY_CLASSES_ROOT\txtfile\shell\open\command] contains the default editor to open a textfile. Can you query this key to find the app, then use this to input the default text you require?
0
craigewensCommented:
A little extra just to be aware.. if you google search that registry location, you'll find the first 50 entries or so solely talk about a virus/worm.. this might make searching for help on this subject a little tougher :(
0
vinnyd79Commented:
Try this:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_SETTEXT = &HC

Private Sub Command1_Click()
Dim lNotepadHwnd As Long, lNotepadEdit As Long
Shell "Notepad.exe", vbNormalFocus
lNotepadHwnd = FindWindow("Notepad", vbNullString)
lNotepadEdit = FindWindowEx(lNotepadHwnd, 0&, "Edit", vbNullString)
SendMessageSTRING lNotepadEdit, WM_SETTEXT, 256, "This is The Text I want to send"

End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.