Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / October 2008

Tip: Looking for answers? Try searching our database.

Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Arnie - 10 Oct 2008 11:35 GMT
is it possible to control Notepad from a macro ie open a new notepad, paste
data in and then save as.

If so how do i call notepad in VB

thanks in advance
Joel - 10 Oct 2008 11:47 GMT
Not sure why you don't just save the Excel file as TEXT, Paste data (use
PasteSpecial Text only") into new Excell Workbook and save as Text.  You
could open Word and paste data into word and then save word as a text
document.

> is it possible to control Notepad from a macro ie open a new notepad, paste
> data in and then save as.
>
> If so how do i call notepad in VB
>
> thanks in advance
Joel - 10 Oct 2008 11:59 GMT
You can open notepad with the following statements and then change the focus
to the NotePad window with these commands

Root = Environ("SystemRoot")

ID = Shell(Root & "\Notepad.exe")
AppActivate ID

Use copy commnd from excel to put data into Cliupbord before opening Notepad
and changing the focus.  Then use "SendKey" commnd to send the key stokes
required to Notepad.  You can use the ShortCuts in NotePad like Cntl+V to
paste.

> is it possible to control Notepad from a macro ie open a new notepad, paste
> data in and then save as.
>
> If so how do i call notepad in VB
>
> thanks in advance
Arnie - 10 Oct 2008 12:21 GMT
Thanks i did find this

Shell "notepad.exe", vbNormalFocus
   Application.SendKeys ("^V")

which works for opening and pasting
but i can't find anything for SaveAs

i am selecting data from different sheets in excel then using notepad to
paste this data into. the notepad is then saved as a script file. Hence the
need to control notepad

> You can open notepad with the following statements and then change the focus
> to the NotePad window with these commands
[quoted text clipped - 15 lines]
> >
> > thanks in advance
Joel - 10 Oct 2008 13:49 GMT
My code is equivalent to yours but is more robust by specifying the ID
(incase multiple NotePad applications are open) and wil work if a different
folder is the default folder.

Root = Environ("SystemRoot")

ID = Shell(Root & "\Notepad.exe", vbNormalFocus)
SendKeys "^v", Wait:=True
SendKeys "^s", Wait:=True
SendKeys "%n", Wait:=True
SendKeys "c:\temp\abc.txt{Enter}", Wait:=True

> Thanks i did find this
>
[quoted text clipped - 27 lines]
> > >
> > > thanks in advance
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.