VBScript - Using Word / Office Macros 
Author Message
 VBScript - Using Word / Office Macros

Hi,

I'm posting this question again, since the reply I've got used VBA and I
meant VBScript.

So here it is:
1. Is there a way of calling VB functions that are found within a Word /
Office
document ("Macro") using ASP / VBScript, assuming the file is found on the
server side.

Example:
Let's say there is a Word document found on the server.
This document has one variable called UserName.
Whenever a user wants to download a file, prior of downloading it, I want to
set this variable to a new value (current user name).

Is it possible ?
Is it possible doing it without opening the file (Word document) ?
How do I refer to a specific document ?

2. Is there a way of adding code / Macro to a Word / other office document.
Again, using VBScript.

Regards,
Ran Chen,



Tue, 15 Apr 2003 00:57:52 GMT  
 VBScript - Using Word / Office Macros

Surely you can translate simple VBA code to VBScript ;-)...

What I gave you in that reply was sufficient to show you how to do what you asked.

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> Hi,

> I'm posting this question again, since the reply I've got used VBA and I
> meant VBScript.

> So here it is:
> 1. Is there a way of calling VB functions that are found within a Word /
> Office
> document ("Macro") using ASP / VBScript, assuming the file is found on the
> server side.

> Example:
> Let's say there is a Word document found on the server.
> This document has one variable called UserName.
> Whenever a user wants to download a file, prior of downloading it, I want to
> set this variable to a new value (current user name).

> Is it possible ?
> Is it possible doing it without opening the file (Word document) ?
> How do I refer to a specific document ?

> 2. Is there a way of adding code / Macro to a Word / other office document.
> Again, using VBScript.

> Regards,
> Ran Chen,




Tue, 15 Apr 2003 09:36:01 GMT  
 VBScript - Using Word / Office Macros

Hi,

Thanks again for your reply.

However, I still cannot open (or access) a Word document.

This is the code I'm using:

    Set WordApp = CreateObject("Word.Application")
    Set WordDoc = WordApp.Documents.Open  ("d:\temp\Wordtest.doc") 'the file
location on the server
    WordApp.Visible = True 'does nothing (?)
    WordApp.Run "Macro1" 'doesn't run the macro (?)
    WordDoc.PrintOut 'Background:=False 'does not print the document (?)
    WordDoc.Save 'does not save the file
    Set WordApp = Nothing

Microsoft office is installed on the server. Do I need to install another
component to make this code work ?

10x,
Ran


Quote:
> Surely you can translate simple VBA code to VBScript ;-)...

> What I gave you in that reply was sufficient to show you how to do what
you asked.

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --



Quote:
> > Hi,

> > I'm posting this question again, since the reply I've got used VBA and I
> > meant VBScript.

> > So here it is:
> > 1. Is there a way of calling VB functions that are found within a Word /
> > Office
> > document ("Macro") using ASP / VBScript, assuming the file is found on
the
> > server side.

> > Example:
> > Let's say there is a Word document found on the server.
> > This document has one variable called UserName.
> > Whenever a user wants to download a file, prior of downloading it, I
want to
> > set this variable to a new value (current user name).

> > Is it possible ?
> > Is it possible doing it without opening the file (Word document) ?
> > How do I refer to a specific document ?

> > 2. Is there a way of adding code / Macro to a Word / other office
document.
> > Again, using VBScript.

> > Regards,
> > Ran Chen,




Fri, 18 Apr 2003 00:21:15 GMT  
 VBScript - Using Word / Office Macros

<%
Dim oWord, oWDoc
Set oWord = Server.CreateObject ("Word.Application")
With oWord
 Set oWDoc = .Documents.Open (Server.MapPath (("d:\temp\Wordtest.doc"))
 .Run "Macro1"
End With
With oWDoc
 .PrintOut False
 .Save
End With
Set oWDoc = Nothing
Set oWord = Nothing
%>
<

Try that.

--
Dominic

Read The Docs? http://msdn.microsoft.com/scripting


Quote:
> Hi,

> Thanks again for your reply.

> However, I still cannot open (or access) a Word document.

> This is the code I'm using:

>     Set WordApp = CreateObject("Word.Application")
>     Set WordDoc = WordApp.Documents.Open  ("d:\temp\Wordtest.doc") 'the
file
> location on the server
>     WordApp.Visible = True 'does nothing (?)
>     WordApp.Run "Macro1" 'doesn't run the macro (?)
>     WordDoc.PrintOut 'Background:=False 'does not print the document (?)
>     WordDoc.Save 'does not save the file
>     Set WordApp = Nothing

> Microsoft office is installed on the server. Do I need to install another
> component to make this code work ?

> 10x,
> Ran



> > Surely you can translate simple VBA code to VBScript ;-)...

> > What I gave you in that reply was sufficient to show you how to do what
> you asked.

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --


> > > Hi,

> > > I'm posting this question again, since the reply I've got used VBA and
I
> > > meant VBScript.

> > > So here it is:
> > > 1. Is there a way of calling VB functions that are found within a Word
/
> > > Office
> > > document ("Macro") using ASP / VBScript, assuming the file is found on
> the
> > > server side.

> > > Example:
> > > Let's say there is a Word document found on the server.
> > > This document has one variable called UserName.
> > > Whenever a user wants to download a file, prior of downloading it, I
> want to
> > > set this variable to a new value (current user name).

> > > Is it possible ?
> > > Is it possible doing it without opening the file (Word document) ?
> > > How do I refer to a specific document ?

> > > 2. Is there a way of adding code / Macro to a Word / other office
> document.
> > > Again, using VBScript.

> > > Regards,
> > > Ran Chen,




Fri, 18 Apr 2003 01:58:20 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using VBScript within Office Macros

2. Debugger doesn't work on Macros for Word in Office XP

3. Word Macro available to other Office applications?

4. Word Macro Selection.range.insertdatabase Office XP/2002

5. I need vc ide macro help, trying to create a move to end of word macro

6. Will Office-97 VBA macros work in Office-XP

7. Word 97 Macros > Word XP Macros

8. VBScript and Word Macros

9. Call Word macro from VBScript

10. Calling Word-Macro from VBScript WITH VARIABLES?

11. Converting Outlook VBScript to VBA as Word Macro

12. find/replace in a Word Doc using word object and vbscript

 

 
Powered by phpBB® Forum Software