I have a worksheet with a command button. When clicking
this button, I want to open a Word document called
agenda.doc. I have used the shell function but this can
only open the application and not the specific filename.
What can I do in order to open other programmes within a
worksheet by clicking command buttons.
Thanks
Kevin
One way:
Private Sub CommandButton1_Click()
Dim obj As Object
Set obj = CreateObject("Word.Application")
obj.Visible = True
obj.Documents.Open "H:\EXCEL\Tests_Development\TestDocument.doc"
Set obj = Nothing
End Sub
---------------------------------------------------------
Hank Scorpio
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
* Please keep all replies in this Newsgroup. Thanks! *
Set wdApp = CreateObject("Word.application")
Stop
'from here on you can issue MSWord macro commands
'but prefixed with "wdApp." (don't forget the dot after wdApp)
'commands not prefixed by "wdApp."
'will be directed to "Application" i.e. to Excel.Application
WdApp.Documents.Close 'should close all docs
Set wdApp = Nothing 'should end the application
end sub
If you just want to start the application and open a specific document for
the user to edit, the Shell function can do that I think
sub test2()
Dim Reply as variant
Reply = Shell("""C:\Program Files\Microsoft Office\Office\Winword.exe""
""DocPath\DocName.doc""", 1) '(this is all one line)
'The extra quotes permit spaces in the path or file names
Application.WindowState=xlMinimized 'get out of the way of word
end sub
HTH
Graham
"Kevin Docherty" <kevin.d...@centrica.co.uk> wrote in message
news:0cd801c329ae$b9688930$a101...@phx.gbl...
On Tue, 3 Jun 2003 11:16:06 +0100, "Graham S" <Gra...@nospam.net>
wrote:
>If you are automating the Word procedure
>sub test()
>Dim wdApp As Object
>
> Set wdApp = CreateObject("Word.application")
[Snip]
> Set wdApp = Nothing 'should end the application
Not quite. All that does is to clear the reference to the Word
application object from your variable. The application itself, once
started, will remain unaffected. To end the application, you would use
the application's Quit method:
wdApp.Quit
"Hank Scorpio" <Apoll...@Hates.Spam> wrote in message
news:j6drdvgoull6vsrrh...@4ax.com...