PDA

View Full Version : Simple XL launcher exe.



Staticbob
10-26-2004, 04:43 AM
Guys,

I need a file that will launch a chosen Excel file. I will be using this on our citrix farm.

I have a workbook with 2 columns. Column A contains the Project Name, Column B contains the path for that projects workbook.

So, I need a small app that will give a list of project names, then when chosen and OK clicked, it will pass the relevant path to Excel and open it. Thats the easy bit, I think !

I also need it to detect if the file is already open, and then disallow the read-only prompt. (This doesn't show in Citrix anyway for some reason, so the users are working on it concurrently.) So if the file is already open, show a message "This file is in use by UserName (from Excel)" Then it closes when OK is clicked. Only one user should have this file open at any one time.

Could anybody give me a starter for 10 ?

Cheers
Bob

Gollem
10-26-2004, 07:03 AM
Hi,

see the code. I've used a form with a listbox and a button. Data starts to read at row 1. When you start the form, listbox is filled in. If you then select an item and execute the code of the button, you get a first result.

I hope this gives you a first idea and a good start.
To know which user a file has open is a little bit more work.(searched longtime myself)


Private Sub CommandButton1_Click()
On Error GoTo FileNotOpen
Workbooks.Open ActiveSheet.Cells(ListBox1.ListIndex + 1, 2).Value
Exit Sub
FileNotOpen:
MsgBox "File doesn't exist!"
End Sub

Private Sub UserForm_Activate()
Dim intRow As Integer

'Start on row 1
intRow = 1
Do While ActiveSheet.Cells(intRow, 1).Value <> ""
ListBox1.AddItem ActiveSheet.Cells(intRow, 1).Value
intRow = intRow + 1
Loop
End Sub



Gollem

Zack Barresse
10-27-2004, 10:12 PM
Hi Bob,

Have you seen this link ... ?

http://www.vbaexpress.com/forum/showthread.php?t=1190

I haven't quite got the procedure worked out for myself yet (retreiving the username portion), but Ivan lines it out on his website (link provided in first post) and there is some excellent discussion on the XtremeVB talk website (link also provided) by Mike, Ivan, Mark and Helen. There is an API version and a VBA version. This does what you are asking for.