Excell FileOPenDialog from another App, and listbox multiselect problems

W

What-a-Tool

I have 2 problems -
First, I am using a list box and have "multi-select extended" enabled. When
I click in the box, I want to enable a button if an item is selected,
disable if no items are selected. Problem is, with multi select enabled, my
box won't detect the click. With simple select, this works, but I want
multi. Am i missing something obvious?

Problem 2 :
I am running a vba macro from another application, which it appears doesn't
have a File open Dialog box.
I thought I could use the Excel GetOpenFileName Dialog (code follows)
This works, but obviously I'm doing something wrong here, because I get a
"Server Busy - Switch Apps or Retry" Dialog right after the GetOpenFileName
closes (gives me the filename, but this dialog warning is annoying)
Could someone tell me what I'm doing wrong here, too?

Private Sub btnBrowse_Click()
On Error GoTo Err_btnBrowse_Click
Dim fl As File
Dim eApp As New Excel.Application
'Get the path to a file with the file open dialog box
Set fl = fso.GetFile(eApp.GetOpenFilename)
eApp.Quit
Set eApp = Nothing
txtDirectory.Value = fl.ParentFolder

Err_btnBrowse_Click:
'Do Nothing
End Sub

Thanks in Advance...

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
T

Tom Ogilvy

The change event will fire on each selection

in your second problem, why do you start a new instance of Excel. If your
code resides in Excel, you don't need to start a new instance to use the
getopenfilename.
 
W

What-a-Tool

Thanks for the help with the list box problem. That, I AM using in an excel
macro. Could not figure out why the click event wouldn't work. Change event
isn't perfect for me, but I can get things working.

The other problem is not from an excel macro. That is for a macro I'm
writing in a program called SolidWorks.
I know it doesn't really belong in this group, but seeing as this group IS
full of vb experts, I was hoping someone would see my error (other than the
wrong group posting, that is)

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
W

What-a-Tool

Yes it does. Its a VBA macro that I am writing for it.

This is what I got on the SW NewsGroup (From: "That70sTick"):

<<<<<The Windows Common Dialog object used for
opening/saving/colors/priniting is not licensed for use in SW VBA. You
have to access it using Windows API calls (Declare...etc.).>>>>

I could do this, but its a lot of code. Probably will end up going with
this, unless someone has a solution for using the Excel application dialog?

The easiest way to do it is by declaring the Excel application object and
using the GetOpenFileName Dialog from that. (Well, it would be if it worked
properly, anyway - but it doesn't). Gives me the "Server is Busy - Retry or
Switch" message. I'm not on a network, either

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 
N

NickHK

Sean,
Go the API way. It's not much code and will avoid your Excel problems.

NicHK
 
W

What-a-Tool

Thanks for the advice. Will do.

Not often that the easy way out is the right way out I guess.
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top