/    Sign up×
Community /Pin to ProfileBookmark

Open Excel document

Hi all
I searched the forum and found the code below and created a page to test it. The code opens Excel fine but does not open the file. Can anyone point out where the error is. I am using my home computer and the files are both located on the C Drive.
<script language=”JavaScript”>
function startExcel(strFile)
{
var myApp = new ActiveXObject(“Excel.Application”);
if (myApp != null)
{
myApp.Visible = true;
myApp.Workbooks.Open(strFile);
}
}
</script>
<p>You can now start Excel with a hyperlink:</p>
<a href=”javascript:startExcel(‘C:Documents and SettingsMeMy DocumentsCraigs StuffDaily_work_record.xls’)”>Test.xls</a>.
</body>
</html>
Thanks for reading this
Craig

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@ricpJan 05.2007 — If you are doing this from your own machine browny, look into using an .htc, as that allows you the privilege to open Excel and control the object created. Whereas a webpage like above, won't.

wscript is also very useful for these sorts of stuff.

Google either of these and you should find a fair amount of info (especially the MSDN site).
Copy linkTweet thisAlerts:
@TNOJan 06.2007 — If you are doing this from your own machine browny, look into using an .htc...[/quote]

Don;t you mean .hta? An .htc is used primarily to create custom tags and namespaces
Copy linkTweet thisAlerts:
@ricpJan 06.2007 — Sorry, my bad, .hta ?
Copy linkTweet thisAlerts:
@brownyauthorJan 20.2007 — Hi there

Did a serach as advised and did find information regarding .hta but I could not find anywhere that put it into context for the way I need to use it. Do you change the file extension or just add .hda to the end of the file name.

Thanks

Browny
Copy linkTweet thisAlerts:
@hgedikliJan 20.2007 — You can open it with WScript.Shell.It works in only local intranet.

var t = new ActiveXObject("WScript.Shell");

t.Run("c:test.xls");
×

Success!

Help @browny spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...