Solved

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

Posted on 2002-07-19
8
1,799 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using Currency Layer API within ASP 10 81
C# page opens in new window 3 55
Add server behaviors to Dreamweaver CC 2015 2 130
classic asp checkbox uncheck and check 2 58
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…
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/…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

22 Experts available now in Live!

Get 1:1 Help Now