Solved

Open an excel file from word macro in the same path

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now