ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening files (https://www.excelbanter.com/excel-programming/274354-re-opening-files.html)

Dan E[_2_]

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






All times are GMT +1. The time now is 09:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com