سؤال

First off, I'm fairly new to the webpage creation deal, but I have done a decent amount of research.

What I am looking for is a way to browse for a file, then collect its path as a variable, from an HTML page. This will be a client-side Excel file, which will then run a macro and return a result.

I realize that what I am trying to do is usually not possible (or at least not recommended), however the tool I am working on has very limited and controlled use (I can specify the environment, including which browser, browser version, operating system, and pretty much anything else).

Knowing this, I have the second half working: I'm using a roundabout method of Firefox, the IE Tab extension, and ActiveX to open and run the Excel macro successfully. Right now though, I specify the Excel file's path; I'd like to give the user the option to choose the file. Is there a way to do this (I'm guessing in ActiveX)?

A bonus would be specifying the starting directory for the browse dialog box.

EDIT:

Some progress (I think) - I've added the following to my Javascript and get a "Type mismatch" error testing in IE9. I think it may have something to do with the quoting of "msoFileDialogFilePicker", but removing the quotes makes Javascript think it's a variable.

Excel = new ActiveXObject("Excel.Application"); Excel.FileDialog("msoFileDialogFilePicker").Show

However, this file picker seems to be exactly what I want.

هل كانت مفيدة؟

المحلول

Using Application.GetOpenFilename works. See here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top