Solved

Open an excel file from word macro in the same path

Posted on 2006-11-20
5
1,577 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:

770 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