473,770 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WScript syntax for creating a new document based on a Word template

Hi,

(Posted this in scripting.wsh before I realised that it might be better
placed here - sorry if you;ve got two copies)

I want my (IE) Intranet users to be able to create a new Word document
based on a specified template.

The following works, but I would like to be able to pass the filename
as a parameter, as there are often multiple documents on the same page:

---------------Script Code Starts-------------
<script lang="Javascrip t1.2">

function NewDoc()
{
var oShell
oShell = new ActiveXObject ("WScript.Shell ");
oShell.Run('cmd /K "C:\\Test.dot"' , 0, false);
window.event.ca ncelBubble = true;
return false;
}
</script>
---------------Script Code Ends-------------
---------------Link Code Starts-------------
<a href=":" onclick="return NewDoc()">Creat e a new document based on
C:\Test.dot</a>
---------------Link Code Ends--------------

I know to specify the document template name as follows:

---------------Link Code Starts-------------
<a href=":" onclick="return NewDoc('C:\\Tes t.dot')">Create a new
document based on C:\Test.dot</a>
---------------Link Code Ends--------------

And change the "Function NewDoc()" in the script code to line to
"Function NewDoc(Template Name)". The problem is that I don't know what
syntax to use to parametise the
"oShell.Run('cm d /K "C:\\Test.dot"' , 0, false);"
line.

Thank you very much - and, while I'm at it, if you are able to point me
to a library of WSH sample files and/or a resource for learning how to
use WSH within an Intranet context, I'd be very grateful.

Regards

Gary Bartlett

Dec 1 '05 #1
1 4177
VK

GaryB wrote:
Hi,

(Posted this in scripting.wsh before I realised that it might be better
placed here - sorry if you;ve got two copies)

I want my (IE) Intranet users to be able to create a new Word document
based on a specified template.
Note 1: you have to double backslashes in the path!

Note 2: if you have any further questions about the JavaScript part you
are welcome. But the usage of WScript.Shell goes beyond the scope of
this group IMHO. You should insist on the answer in the related
newgroup.

<html>
<head>
<title>Word</title>
<script type="text/javascript">
var oShell = null;

function init(path) {
oShell = new ActiveXObject(' WScript.Shell') ;
oShell.Run('win word.exe /t '+path, 1, false);
}

</script>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFF F" onload="init('c :\\Template.doc ')">

</body>
</html>

Thank you very much - and, while I'm at it, if you are able to point me
to a library of WSH sample files and/or a resource for learning how to
use WSH within an Intranet context, I'd be very grateful.


You may start from here:
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/script56/html/wsmthrun.asp>

Dec 1 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
50588
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork = WScript.CreateObject("WScript.Network") sPwd = inputbox("Enter password") WshNetwork.MapNetworkDrive "J:", "\\server1\data", false, "xyz_net\John", sPwd Msgbox "Drives has been map successful"
1
3353
by: nuve | last post by:
Hi Please help.. What I want to do is to create a web form that once submitted it takes the fields and opens a new instance of a Word Template and populates bookmarks within the document with the fields from the web form, then saves it to a specified location with a specified name... does anyone know of an article or tutorial about this.... cheers nuve
19
2975
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $ Last-Modified: $Date: 2003/09/22 04:51:49 $ Author: Nicolas Fleury <nidoizo at gmail.com> Status: Draft Type: Standards Track
3
5393
by: Richard Fritzler | last post by:
I was given the task of designing a complete web based document prep system. In simplest terms (using a msword explanation) create a database of merge fields, and a library of templates. Allow the webuser to select the template, merge his DB record, and produce a formatted document that can be printed or downloaded. We need to do this without specialized software on the client, since it will be universally available to webusers. We...
0
1099
by: Mr. T. | last post by:
Hi, i've got a word-template based on which i make a word-document throught automatisation from within my access vba-module. So far, no problem. Now the lay-out of the document needs to be changed from within my access module depending on the content i'm sending to word. The document consists of a fixed header, where i put some data, but that's no problem, i've put my fields there, with bookmarks, and they get filled
4
2695
by: Nikhil Patel | last post by:
Hi all, I need to generate a word document and save it on the server from an ASP.Net application. Basically I want to load a word template and insert some field values from a dataset and save the final output as a Word document. I know there are different options to do this. But I can't decide which one I should use. I don't want to use automation on the server because of scalability issues and it is not recommended by Microsoft. So I am...
10
354
by: nondisclosure007 | last post by:
I am actually trying to do this and found in this thread some very good information (begin quote): { In ASP.NET you should store and manipulate the word document on the server. You can manipulate it either through the Word object model (which is not really supported or encouraged, but does work), or you can save the document as XML and manipulate the XML.
5
2121
by: outstretchedarm | last post by:
I'm extremely new to javascript and to programming in general. I am trying to create an interactive table. I have already created the table with constants, in the key of C (it is for music). what I would like to do is to create a dropdown box that would enable the user to select all 12 keys, then based on that choice, have the whole table re-calculate, basically transposing all the data up or down. how would I go about doing this.
2
4951
by: mburns | last post by:
Hello all- I was wondering if it is possible to link an Access query or table to a Word document and pull specific information into Word by manually entering a unique identifier, which would then pull all related fields from Access to the Word document. My goal is to develop a Word template that pulls certain fields from an Access query or table. For example, some of the fields I would like to pull from Access are etc..... But I would...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.