Open file based on cell value

neilholmes

New Member
Joined
Feb 17, 2011
Messages
13
Hi all,

I am currently writing a vb code that when used does several different tasks... One of the tasks involves the code opening a word template:

Code:
' The following code opens the relevent template file - FUND1 Template
Set wordapp = CreateObject("word.Application")
      wordapp.documents.Open "E:\FUND1.dot"
      wordapp.Visible = True

This works fine. However in using this code, the path needs to be changed for each word document opened, and therefore a code written for each path.

I would like the code to look up the path based on a reference in a cell. So the path is not actually written in the code. For example cell A1 contains the path (text) "E:\FUND1.dot". My code would therefore go to cell A1 for the file it needs to open. Something look something like this:

Code:
' The following code opens the relevent template file - FUND1 Template
Set wordapp = CreateObject("word.Application")
      wordapp.documents.Open "A1"
      wordapp.Visible = True

But obviously its not that simple... Can anyone help with this please ?

Thanks

- Neil
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Code:
wordapp.documents.Open Range("A1").Value
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top