Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2002-07-19
8
1,814 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 50

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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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