Solved

Run Word macro on client using ASP (well, Javascript)

Posted on 2002-07-19
8
1,792 Views
Last Modified: 2007-12-19
Hi,
I have created a Word macro on my computer, where I have installed IIS. The macro is defined in my Normal.dot template. The macro concerns doing a mailmerge on a word document, associated with a Excel data source. Now, I want this macro to be run/executed on the clients in the intranet. The macro will be triggered by pushing a button on the web site. I use Javascript (runs on clients), since starting many Word instances would slow my computer/server down I guess.

The problem is that since the macro is not installed on the clients Normal.dot, error occurs when the users click the button. Somehow, I want the clients/users to start word with my Normal.dot so that they can execute the macro. It works fine when I test it, but not on other computers.

Here is the code (javascript):
function ladda()
     {
         word = new ActiveXObject('Word.Application', 'se02ws0108');
     word.visible = true;
     var thedoc = word.Documents.Open("http://clibben/clickprocess/FTR_makroversion.doc");
     word.Run('Macro3');        
          }

Then I trigger it in the html-code by:
<form action="*">
<input type=button value="Create Document" name=knapp onClick="ladda();">
</form>

As you can see, I have tried to start a new ActiveXObject on my computer by naming my computers name (se02ws0108), but that does not help. The users still does not get access/understands the macro.

I hope my problem is reasonable clear?
I will appreciate any help! You would really help me out.

Regards
Harald


ps sorry I named it easy, but I only have 80 points....ds
0
Comment
Question by:Niiii-Knight
8 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7164290
Is this problem will solve if you download the Normal.dot from to the local machine?
0
 

Author Comment

by:Niiii-Knight
ID: 7164325
I suppose so. If each client somehow download my macro to their machines and place the macro in the template which is associated with the document that will do the mailmerge then it will work (maybe?!) I understand that security issues like trust oknown ActicveXobjetc etc will araise, but I think that will be ok on the intranet, as it is now I would like it to work.


Regards
Harald
0
 

Author Comment

by:Niiii-Knight
ID: 7164336
I suppose so. If each client somehow download my macro to their machines and place the macro in the template which is associated with the document that will do the mailmerge then it will work (maybe?!) I understand that security issues like trust oknown ActicveXobjetc etc will araise, but I think that will be ok on the intranet, as it is now I would like it to work.


Regards
Harald
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 7171785
Wow, a bit dangerous downloading your normal.dot to every web client. Why don't you just put the macro into a normal document and download that? The macro can then be called from client side.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Niiii-Knight
ID: 7181316
OK, I would really appreciate if you explanied how it would be done in more detailed steps (technical) since I have problem solving this issue. How do I "put" a macro into a "normal" document, for instance? When a document is created it is associated with a macro, as I understand it. But how does it get sent along with a document?

/Harald
0
 

Expert Comment

by:Temp999
ID: 7251613
Niiii-Knight

I understand what you are trying to do and I think it is a vwry bad idea for many reasons.

But if you really must do it here is a very simple yet inefficient and potentially server crashing way


Create a VB Dll.
----------------------------------------------------------
Step 1. Create a VB Dll.
Step 2. Name the Project TO an Appropriate Name ie myWord
Step 3. Name the Class To an Appropriate Name ie myWordClass
Step 4. Add a Method to the Class and Give it an appropriate Name ie StartWordMacro
Step 5. (Optional) Give the Method parameters. In my example I will not.
Step 6. Add the following code to the Method

'This code was just modified from the code you provided
'But was just made VB Specific

Dim w As Word.Application
Dim doc As Word.Application

Set w = New Word.Application
w.Visible = True

doc = w.Documents.Open("http://clibben/clickprocess/FTR_makroversion.doc");

w.Run('Macro3');        

Set up IIS
----------------------------------------------------------
Step 1. Create an ASP Page with the following Code
<%


%>






0
 

Expert Comment

by:Temp999
ID: 7251617
Niiii-Knight

I understand what you are trying to do and I think it is a vwry bad idea for many reasons.

But if you really must do it here is a very simple yet inefficient and potentially server crashing way


Create a VB Dll.
----------------------------------------------------------
Step 1. Create a VB Dll.
Step 2. Name the Project TO an Appropriate Name ie myWord
Step 3. Name the Class To an Appropriate Name ie myWordClass
Step 4. Add a Method to the Class and Give it an appropriate Name ie StartWordMacro
Step 5. (Optional) Give the Method parameters. In my example I will not.
Step 6. Add the following code to the Method

'This code was just modified from the code you provided
'But was just made VB Specific

Dim w As Word.Application
Dim doc As Word.Application

Set w = New Word.Application
w.Visible = True

doc = w.Documents.Open("http://clibben/clickprocess/FTR_makroversion.doc");

w.Run('Macro3');        

Set up IIS
----------------------------------------------------------
Step 1. Create an ASP Page with the following Code

<%@ Language=Javascript %>
<%


%>






0
 

Accepted Solution

by:
Temp999 earned 50 total points
ID: 7252279
Niiii-Knight

I understand what you are trying to do and the business requirements are valid but the architecture of the solution you are proposing is very inefficient and troublesome.

Let me say that I would not recommend doing what you are atrying to do ... But if you really must do it here is a very simple way.


Create a VB Dll.
----------------------------------------------------------
Step 1. Create a VB Dll.
Step 2. Name the Project TO an Appropriate Name. ie myWord
Step 3. Name the Class To an Appropriate Name. ie myWordClass
Step 4. Add a Method to the Class and Give it an appropriate Name. ie StartWordMacro
Step 5. (Optional) Give the Method parameters.

Step5 Note. In my example I will not because im trying to keep it as simple as possible.

Step 6. Add the following code to the Method
Step 6 Note This code was modified from the code you provided but was just rewritten in VB.

Dim w As Word.Application
Dim doc As Word.Application

Set w = New Word.Application
w.Visible = True

doc = w.Documents.Open("http://clibben/clickprocess/FTR_makroversion.doc");

r.Run("Macro3")        

Set up IIS
----------------------------------------------------------
Step 1. Create an ASP Page with the following Code
Step 1 Note. Replace myWord,  myWordClass , and StartWord Macro to what you called them.

<%@ Language=Javascript %>
<%
//This is in Javascript since you seem to prefer it

var w;

w = new ActiveXObject("myWord.myWordClass");
w.StartWordMacro();

%>


Step 2. (I am assusuming you have IIS 5.0.) Open the ISS mmc and go to the Directory Security Tab

Step 3.Edit the Anonymous access and authentication control

Step 4. Make sure you only have Integrated Windows authetication checked.






0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now