View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dan E[_2_] Dan E[_2_] is offline
external usenet poster
 
Posts: 102
Default Opening files

Ben,

The first thing you need to do is add references to word and
powerpoint to your project.

"Tools" - "References" and check off
Microsoft Word X.X Object Library
Microsoft PowerPoint X.X Object Library
where X.X is your version of Word/Powerpoint

Then to open a word document

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
OpenWhat = Application.GetOpenFilename("Microsoft Word Documents (*.doc), *.doc")
Set wdDoc = wdApp.Documents.Open(OpenWhat, , True)
wdApp.Visible = True

To open a powerpoint file

Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Set ppApp = CreateObject("PowerPoint.Application")
OpenWhat = Application.GetOpenFilename("Microsoft PowerPoint Presentation (*.ppt), *.ppt")
Set ppPres = ppApp.Presentations.Open(OpenWhat, msoFalse, msoFalse, msoFalse)
ppApp.Visible = msoCTrue

Dan E


"Ben E" wrote in message ...
Hi all

I am looking for a little help, what I would like to do is
open files from within another application namely MS Word,
i.e. when the user presses the button a Word document will
be opened and activated, I also need for the file to open
as read only.

I also need to do the same for a PowerPoint file.

Any help would be appreciated

Cheers
Ben