Solved

Open an excel file from word macro in the same path

Posted on 2006-11-20
5
1,580 Views
Last Modified: 2008-01-09
I have two docs on a network share. Different people will see different paths to the same documents.
I need to have word open an excel doc in the same path without specifing the full path because each person will map the network share to different drives.

I know excel can use Thisworkbook.path
Is there a similar command I can use to open the excel doc from a word macro?

EDIT
I found ActiveDocument.Path in the macro help window. I don't know how to write the macro to open an excel file let alone use this ActiveDocument.Path statement.
The excel file I wish to open is called Clients.xls.

Thanks in advance for the help.
0
Comment
Question by:SpyderGST1
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:YoungBonzi
ID: 17985085
Hello,

This should do it:

Workbooks.Open(ThisWorkbook.Path + "\Clients.xls")

Hope it helps!
0
 
LVL 7

Accepted Solution

by:
gbahri earned 250 total points
ID: 17985318
Hi SpyderGST1,

You can use the following code to open excel workbook from Word macro, here is the code:


Sub OpenExcel()
   
    Dim ExcelSheet
    Set ExcelSheet = CreateObject("Excel.Application")
    ExcelSheet.Visible = True
    ExcelSheet.Workbooks.Open ActiveDocument.Path & Application.PathSeparator & "Client.xls"

End Sub

Hope, this serves your purpose,

Thanks,

GBahri
0
 

Author Comment

by:SpyderGST1
ID: 17988869
youngbonzi,
Thank you for your response but you suggestion did not work.
0
 
LVL 8

Expert Comment

by:YoungBonzi
ID: 17988937
Ohh, well glad the other way did =]
0
 
LVL 7

Expert Comment

by:gbahri
ID: 17993083
Thanks,

GBahri
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question