I have this code that I got from these forums (can't remember who posted it...sorry) that pastes text directly into Notepad.
This works like a champ. What I need to do is modify this to paste the text into a blank word document, so I changed it to thisVB Code:
Dim lnghWnd1 As Long Dim lnghWnd2 As Long Dim sText As String Clipboard.Clear Clipboard.SetText Text1.Text Shell "notepad", vbNormalFocus lnghWnd1 = FindWindow(vbNullString, "Untitled - Notepad") lnghWnd2 = GetWindow(lnghWnd1, GW_CHILD) sText = Clipboard.GetText SendMessage lnghWnd2, WM_SETTEXT, Len(sText), sTextHowever, it does not paste the text into the document. The text is on the clipboard. When the word document opens, if I do a Ctrl-V or an Edit/Paste, the text is copied to the document, but I need it to be there without having to paste it myself.VB Code:
Dim lnghWnd1 As Long Dim lnghWnd2 As Long Dim sText As String Dim objWord As Word.a Clipboard.Clear Clipboard.SetText Text1.Text Shell "c:\program files\microsoft office\office11\winword.exe", vbNormalFocus lnghWnd1 = FindWindow(vbNullString, "Document1 - Microsoft Word") lnghWnd2 = GetWindow(lnghWnd1, GW_CHILD) sText = Clipboard.GetText SendMessage lnghWnd2, WM_SETTEXT, Len(sText), sText
I don't want the text pasted into an existing document, I need the text pasted into a new, blank, document1, Word document.
How would I do that?




) that pastes text directly into Notepad.
Reply With Quote