Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6,582
Default Opening a Word Document using an Excel (2000) Macro?

You're welcome. It actually only took about five minutes, by copying much of
it from the page I cited, then making appropriate changes.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"ekreider" wrote in message
...
Jon,

Thank you for your hard work.
I know it took you a little while to get all this wrtten down.

Thank you again.

Thanks,

ekreider
"Jon Peltier" wrote:

This page lays some of the groundwork:

http://peltiertech.com/Excel/XL_PPT.html

The late-binding code to open a Word document from Excel is:

Function OpenWordDoc(sDocFullName As String) As Object
Dim wdApp As Object
Dim wdDoc As Object
Dim sDocName As String

' Reference instance of Word
On Error Resume Next
' Check whether Word is running
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then
' Word is not running, create new instance
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
End If
On Error GoTo 0

' Check whether document is open
sDocName = Mid$(sDocFullName, InStrRev(sDocFullName, "\") + 1)
On Error Resume Next
Set wdDoc = wdApp.Documents(sDocName)
If wdDoc Is Nothing Then
' Document not open, so open it
set wdDoc = wdApp.Documents.Open(sDocFullName)
If wdDoc Is Nothing Then
' Document couldn't be opened
' probably should notify the user
End If
Else
' Document is open, no action required
End If
On Error GoTo 0

Set OpenWordDoc = wdDoc
End Function

Call the function like this:

Dim MyDocument As Object ' Word.Document
Set MyDocument = OpenWordDocument("C:\Temp\MyDocument.doc")

The open document is referenced in the variable MyDocument. If you don't
need to reference the document in an Excel variable, call it like a sub:

OpenWordDocument "C:\Temp\MyDocument.doc"

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"ekreider" wrote in message
...
I am short on time.

Please help to put the code needed to open a Word Document from an
Excel
Macro.
I know it's simple and I am sure you have posted this thousands of
time,
but
may time seems to be getting short to finish this project. Please help.

Thanks,

ekreider








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
opening word document rk0909 Excel Discussion (Misc queries) 0 January 10th 07 02:42 PM
Opening word document through excel vba srinums Excel Discussion (Misc queries) 0 June 8th 06 12:02 PM
opening word doc from excel 2000 and 2003 differences Colin C Excel Discussion (Misc queries) 0 December 11th 05 08:06 PM
Using Excel 2000 as Data source for Word 2000 document Malcolm Agingwell Excel Discussion (Misc queries) 2 June 21st 05 09:28 AM
Opening Word Document with excel [email protected] Excel Discussion (Misc queries) 0 March 21st 05 01:49 AM


All times are GMT +1. The time now is 12:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"