Footer in Word

J

JP SIngh

I have an urgent request wonder if someone can help

I need sample code in ASP which allows me to open a word file and write the
record id as footer. Can this be done if so how?

I know how to open files using the file system object just don't know how to
create a footer automatically in ASP.

Thanks in advance for your help.
 
M

McKirahan

JP SIngh said:
I have an urgent request wonder if someone can help

I need sample code in ASP which allows me to open a word file and write the
record id as footer. Can this be done if so how?

I know how to open files using the file system object just don't know how to
create a footer automatically in ASP.

Thanks in advance for your help.


How Can I Put the User Name into the Footer of a Microsoft Word Document?
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan05/hey0111.
mspx

Of course, MS_Word has to be installed on the server.

Here's an ASP page that does what you want.
Change the values cDIR and cDOC for your purposes.
Call "WordFooter()" with your Record ID.

<% @Language="VBScript" %>
<% Option Explicit
Const cDIR = "C:\Inetpub\wwwroot\Temp\"
Const cDOC = "MS_Word.Doc"
Response.Write "WordFooter() = " & WordFooter(123)

Function WordFooter(id)
WordFooter = False
Dim objAPP
Set objAPP = CreateObject("Word.Application")
objAPP.Documents.Add
Dim objDOC
Set objDOC = objAPP.ActiveDocument
objDOC.Sections(1).Footers(1).Range.Text = id
objDOC.Sections(1).Footers(1).Range.ParagraphFormat.Alignment = 1
objAPP.ActiveDocument.SaveAs cDIR & cDOC
objAPP.Quit
Set objAPP = Nothing
Set objDOC = Nothing
WordFooter = True
End Function
%>
 
J

JP SIngh

Hi Mckirahan

Thanks for the reply. The code appears to work as it does not throw any
errors but where is it creating the new document and where is it being
saved.

Please help.

Thanks
Jas
 
M

McKirahan

JP SIngh said:
Hi Mckirahan

Thanks for the reply. The code appears to work as it does not throw any
errors but where is it creating the new document and where is it being
saved.

Please help.

Thanks
Jas

[snip]

As I said:

"Change the values cDIR and cDOC for your purposes."

Const cDIR = "C:\Inetpub\wwwroot\Temp\"
Const cDOC = "MS_Word.Doc"


If it works then you'll see the following in your browser:
WordFooter() = True

Otherwise, you'll see:
WordFooter() = False
 

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

Members online

No members online now.

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top