Creating a Word Document from a Web page

P

Peter

Hi,
I'm trying to create a VBscript in web page that either
opens up or creates a word document.

I have a onclick event that calls the following routine.
So far I've tried code along the following lines:
<script language="vbscript">
<!--
function opentr()
'Dim oWord As Variant
'Dim rep_tmplt as String
rep_tmplt = "C:filename.doc"

Set oWord = CreateObject("word.application")
With oWord
.Visible = True
.Activate
' .documents.Add template:=rep_tmplt,
NewTemplate:=False, DocumentType:=0, Visible:=True
End With

End function

-->
</script>

However, you will notice that I have commented out
several lines - that's because FrontPage throws a runtime
error - "expected end of line" when I preview. I
expected this to be straight forward, but I'm obviously
missing something, or I'm trying to do something I'm not
supposed to.

Can anyone help? I initially tried posting on the
FrontPage forum, but they suggested I try in office
developer forum instead. I hope someone here can help,
or let me know where else to try.

Any help would be appreciated.

Peter
 
C

Chad DeMeyer

Peter,

All variables in vbscript are variants - it doesn't allow you to declare
them as a specific type. You will also want a reference to the document
contained in a variable. You could specify the filename as a constant.
Finally, vbscript doesn't accept named arguments - you just have to specify
the values for the arguments in the right order. And you don't need to
specify some of those arguments - you can accept the default values. So
your code would like like this:

function opentr()
dim oWord
dim oDoc

const rep_tmplt = "C:filename.doc"

set oWord = createobject("word.application")
with oWord
.visible = true
.activate
.documents.add rep_tmplt
end with

end function

Regards,
Chad
 
P

Peter

Chad,
I really appreciated your help. This has let me get over
my first hurdle.

Many thanks

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top