Solved

Open an excel file from word macro in the same path

Posted on 2006-11-20
5
1,581 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

729 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