Newbie VBA question

J

Jeff

I would like to script the VBE to select the text in a module and open up
Wordpad, paste the text and save it.

Can I do this?
 
K

Kou Vang

I'm no expert, but in the help, under the find method you will see this
example:

Application.VBE.CodePanes(2).CodeModule.Find ("Tabs.Clear", 1261, 1, 1280,
1, False, False)

once you select the text in the code, you can then open the notepad.exe and
copy and paste the text there.

There is a reference from another question, in which an answer was given.
I'm not sure if I'm suppose to get an okay to copy his answer here. But it
is a newsgroup, and his name is Veign. So don't be mad Veign if you see
this, you've helped me out lots.

Option explicit (Courtesy of Veign)

If you want to open it in Notepad then you could use the ShellExecute API to
open the file:

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'Usage Like
ShellExecute Me.hwnd, "open", "notepad.exe", strFilePath, "c:\", 1

where:
strFilePath is the full path to the file to show.


Kou
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top