Hi all,
I'm attempting to create something that can be used on any workbook open to automatically open a file based on the data in cell. Here's the general idea:
1) User right clicks on a cell.
2) If the cell's value matches an expected format (##-A-####-## for example), a macro is available in the rightclick popup menu.
3) The user selects the macro in the popup menu if they want to run it.
4) The macro takes the cell value and converts it into a filename.
5) The specified file is opened in an external program.
I have everything done for steps 4 and 5, in the following code:
Option Explicit
Dim StdOutPut As Variant
Dim cf, cfJPG, cfDXF, cfDWG, cfPLT As Variant
Dim DwgExists, JpgExists, DxfExists, PltExists As Boolean
Sub GetDrawing()
cf = LCase(ActiveCell.Value)
cfPLT = "\\server\directory\" + cf + ".plt"
cfDXF = "\\server\directory\" + cf + ".dxf"
CheckFile
If DxfExists = True Then
StdOutPut = cfDXF
Call avview 'The external program is called here
ElseIf PltExists = True Then
StdOutPut = cfPLT
Call avview 'The external program is called here
Else
End If
End Sub
Sub CheckFile()
DxfExists = (Dir(cfDXF) <> "")
PltExists = (Dir(cfPLT) <> "")
End Sub
Sub avview() 'launches autovue to view selected file
Dim cmdname
Dim AVcmd, AVexists
AVcmd = "C:\program files\av\avwin\avwin.exe "
cmdname = "C:\program files\av\avwin\avwin.exe " + StdOutPut
Shell (cmdname)
End Sub
The rightclick stuff is a bit more difficult for me. I think I need to get into the BeforeRightClick event, but I'm not sure how to use it and I don't know how to make it so that each user need only add the macro once and then have it available for every workbook from then on.
Any suggestions would be greatly appreciated!
Bookmarks