View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
DGreco DGreco is offline
external usenet poster
 
Posts: 4
Default Programming Excel to open a program

Thanks for the sample code. I understand the concept. The shell command will
open NotePad. But I believe the code in the example is not formatted
correctly to get Notepad to open up the file, "C:\1.txt". I tried it out and
it didn't work. I get this error message:

Compile Error
Syntax Error

This leads me to my next question. I would assume that if the drawing name
is in cell "B2", I can use the following code to save the contents of "B2" to
a variable name.

Set strFname = Range("c2").Value

But if I do this, I get a syntax error because the value of the cell is not
a text string. I would assume that I have to convert it to a string in order
to use in in conjunction with the SHELL command. Correct? if so, how do I
pass the contents of the cell to the shell command in a format is can use?
--
DGreco


"Jacob Skaria" wrote:

Create a file c:\1.txt and try tbe below from Immediate window

shell "c:\windows\NOTEPAD.exe" "C:\1.txt"
--
If this post helps click Yes
---------------
Jacob Skaria


"DGreco" wrote:

I have an application where I want Excel to open a file listed in a
spreadsheet. This spreadsheet contains a list of Autocad drawings. Ordinarily
I'd just use the Hyperlink function to allow the user to click on it and
AutoCad will open the file. However, we have limited netowrk licenses and
they are assigned on a first come basis. If all of the licenses are in use,
and someone tried to open a drawing with AutoCad it will fail. I'd like to
make it so that when the user clicks on the filename, an Autocad viewer will
open.

I was thinking that a command button with some embedded code would do the
trick. The code would look at the cell and get the filename (which includes
the entire path to the drawing). Then the program would open it with the
drawing viewer.

However, I'm at a loss as to HOW to do this. Any help?

DGreco