View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Edwin Tam[_4_] Edwin Tam[_4_] is offline
external usenet poster
 
Posts: 23
Default macro and button to open a word document from within excel

Try the following code
The macro attempts to open a word document called "my_word_document.doc" located in the same directory as the current Excel file
The macro also include quite complete error handling statements

'-----------------------------------------------------
Sub Load_Word_Document(
Dim address_str$, xlApp As Objec
On Error GoTo load_erro
address_str = ThisWorkbook.Pat
If Right(address_str, 1) < Application.PathSeparator Then address_str = address_str & Application.PathSeparato
address_str = address_str & "my_word_document.doc
If Not Dir(address_str) = "" The
Set xlApp = CreateObject("Word.Application"
xlApp.Documents.Open Filename:=address_st
xlApp.Visible = Tru
Els
MsgBox ("Unable to locate the Word document."
End I
GoTo exit_jum
load_error
Shell address_str, vbNormalFocu
exit_jump
Set xlApp = Nothin
On Error GoTo
End Su

'--------------------------------------------

Regards
Edwin Ta

http://www.vonixx.co


----- JAJOSEPHESQ wrote: ----

I would like a macro to automatcially start work and open a sepecifi
MicroSoft Word (Office XP version) from with in MicroSoft Exce
(Office XP version)