simbo Posted December 10, 2007 Share Posted December 10, 2007 Hello All I've written a program that produces RTF files. I have 2 questions:- 1) As I don't know whether or not the end user will have MS Office or OpenOffice, I want to open the files in Wordpad because I know that every Windows user has got Wordpad. If I use shellexecute they open using the default RTF reader, in my case MS Word. Is there some way I can I force them to open in Wordpad without having to change the File Association in Control Panel? 2) Wordpad ignores the margin settings in my documents, and instead uses default settings. Can I use COM or ActiveX or something else to change the margin settings directly from my script. I know I could simulate the keystrokes needed by I think that looks a bit amateurish Many thanks in advance Simbo Link to comment Share on other sites More sharing options...
zfisherdrums Posted December 10, 2007 Share Posted December 10, 2007 (edited) Hello simbo, 1 ) Open Wordpad using shellexecute and pass the RTF file as an argument. Be advised that you may need to wrap the RTF path with quotes to account for paths that contain spaces. $wordpad = "C:\Program Files\Windows NT\Accessories\wordpad.exe" $RTFdoc = "C:\Test.rtf" ShellExecute( $wordpad, '"' & $RTFdoc & '"' ) 2 ) The following registry key appears to persist the margin settings between sessions. Before distributing your script you may be able to open the RTF, change the margins manually, close the app and then capture the data from this key (i.e., RegRead ). Then use RegWrite in your script to change the user's setting to match your's before opening wordpad. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Wordpad\Options\PageMargin Hope this helps, Zach... Edited December 10, 2007 by zfisherdrums Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
DjDeep00 Posted December 10, 2007 Share Posted December 10, 2007 I would use Run(@ComSpec & " /c " & 'start wordpad C:\Filename.txt', "", @SW_HIDE). Link to comment Share on other sites More sharing options...
simbo Posted December 13, 2007 Author Share Posted December 13, 2007 Many thanks guys - I can't believe how easy that was! My program is now up and running (well, apart from the million and one ways I keep thinking of to feature-bloat... err... I mean improve it's functionality! Thanks again Simbo Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now