Hello,
I have a rough script which follows. It grabs text from a Word document and puts
it into a text file via Notepad. It is run from a command line with 'cscript
/nologo myscript.vbs'. I would like to make it a lot simpler by using pspad
instead.
Is is possble to invoke pspad from wsh in the same way that you can invoke word?
I want to lose the sendkeys commands and copy data between 2 objects instead.
What's the equivalent of
Set objWord = CreateObject("Word.Application")
for pspad?
n.b. I know I could script word to save as text but I dont want to do that as I
lose some table formatting due to line wraps.
Thanks for all constructive comments.
Hal
~~~~
'myscript.vbs
Const wdFormatText = 2
Const wdStory = 6
Const wdMove = 0
Set objWord = CreateObject("Word.Application")
objWord.Visible = TRUE
Set objDoc = objWord.Documents.Open("c:\test.doc")
Set Selection = objWord.Selection
selection.wholestory
Selection.Copy
objWord.Quit
WScript.Sleep 500
' Open notepad
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad", 9
' Give Notepad time to load
WScript.Sleep 500
' Do The Paste
WshShell.SendKeys "%e"
WshShell.SendKeys "p"
WScript.Sleep 500
WshShell.SendKeys "%f"
WshShell.SendKeys "a"
WScript.Sleep 500
WshShell.SendKeys "c:\fred7383.txt"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "%f"
WshShell.SendKeys "x"
--
<http://forum.pspad.com/read.php?2,44761,44761>
PSPad freeware editor http://www.pspad.com