Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to execute a Word Macro from ASP page 1

Status
Not open for further replies.

kishore22

Technical User
Sep 25, 2002
12
US
Hi,
I need to run a Word macro through ASP page. And also i need to pass some data/variables from ASP page to Word Macro.

thank you.
 
I'm not sure that this is possible. First you would have to be able to pass the user a word document in order for microsoft word to open. This would change the doc type from html to word document, leaving you with no client side scripting ability. It might be possible to open the document in a new window, but then you are rhoping they have the same version of word you do, among many other things. Even if you can do this, again, it may not be possible for aqn outside process to ca,ll a macro (if they even have macros on), and i think most virus programs or firewalls would catch this attempt to run a macro from remote.
-Tarwn "The problem with a kludge is eventually you're going to have to back and do it right." - Programmers Saying (The Wiz Biz - Rick Cook)
"Your a geek!" - My Girlfriends saying
 
Yes you can run a word macro from asp page, as I have discovered. However, passing arguments is proving to be elusive and I'm not even sure you can. My script so far:

Dim sFileNamePath,theBookMark
Set objWord = CreateObject("Word.Application")
objWord.Application.visible=true
sFileNamePath = &quot;<%=busDocs%>&quot;&&quot;NewServicesTables.dot&quot;
objWord.Documents.Open sFileNamePath, NewTemplate = false

objWord.Documents(1).Activate
name = &quot;UNIT1&quot;
ex = 0
prop = 20
v = 400
phs = &quot;Three Phase/50Hz&quot;
cable = &quot;35mm2 Multicore&quot;
fuse = &quot;100A to BS1361&quot;
earth = &quot;PME(TN-C-S)&quot;
mtr = &quot;Whole Current&quot;

objWord.Application.Run &quot;NewServiceTables&quot;,name,ex,prop,v,phs,cable,fuse,earth,mtr


end function
</script>
 
HI,

I was able to run this code and it works locally on my machine. The Word Macro ran and everything is fine.
When I implement the code on a web server that does not have MS Office and the same Word Macro installed, the Macro did not run on the client machine. The client has both the MS Office and Word Macro installed.

I thought this is client side code to execute the Macro on the client computer. Is this true?
 
I figured it out.
The ActiveX scripting permission was not set on the client computer. The Vbscript works!

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top