Modificar encabezados y pie de pagina en un word
Publicado por Bet7o (17 intervenciones) el 14/07/2009 18:53:34
Hola a todos,
Tengo un script que me remplaza todas las coincidencias de un texto en un documento word, pero lo que no logro es poder remplazar tambien el encabezado y pie de pagina.
Les dejo el codigo que eh podido armas asta ahora.
<%@language="vbscript" lcid = "2058" codepage="65001"%>
<!--include file="nocache.asp"-->
<%
'On Error Resume Next
Response.Buffer = True
if request.ServerVariables("REQUEST_METHOD") = "POST" then
Function ReemplazarText(archivo, txtBuscar, txtRemplazar)
Set oWord = server.CreateObject("Word.Application")
oWord.Documents.open archivo
oWord.visible = false
Const wdFindContinue = 1
Const wdReplaceAll = 2
Set objSelection = oWord.Selection
With objSelection.Find
.Text = txtBuscar
.Forward = True
.MatchWholeWord = True
.Wrap = wdFindContinue
.Format = False
.Replacement.Text = txtRemplazar
.Execute ,,,,,,,,,,wdReplaceAll
End With
oWord.ActiveDocument.Save
oWord.Quit
Set oWord = Nothing
End Function
Call ReemplazarText ("E: ootDocAD-OBRA-FOSEG-SINANTICIPO.doc", Request("txt1"), Request("txt2"))
end if
if err.number <> 0 then
response.Write(err.description)
response.End()
end if
%>
<form action="gamasp.asp" method="post">
<table>
<tr>
<td>Buscar:</td>
<td><input type="text" name="txt1" value="" /></td>
</tr>
<tr>
<td>Reemplazar con:</td>
<td><input type="text" name="txt2" value="" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Aceptar" /></td>
</tr>
</table>
</form>
Con este codigo logro remplazar el texto pero no asi los encabezados y pie de pagina, investigando encontre como poner texto pero no reemplazar.
Este es el codigo:
With oWord.ActiveDocument.Sections(1)
.Headers(wdHeaderFooterEvenPages).Range.Text = "cab"
.Footers(wdHeaderFooterEvenPages).Range.Text = "pie"
End With
Espero alguien me pueda ayudar, saludos.
Tengo un script que me remplaza todas las coincidencias de un texto en un documento word, pero lo que no logro es poder remplazar tambien el encabezado y pie de pagina.
Les dejo el codigo que eh podido armas asta ahora.
<%@language="vbscript" lcid = "2058" codepage="65001"%>
<!--include file="nocache.asp"-->
<%
'On Error Resume Next
Response.Buffer = True
if request.ServerVariables("REQUEST_METHOD") = "POST" then
Function ReemplazarText(archivo, txtBuscar, txtRemplazar)
Set oWord = server.CreateObject("Word.Application")
oWord.Documents.open archivo
oWord.visible = false
Const wdFindContinue = 1
Const wdReplaceAll = 2
Set objSelection = oWord.Selection
With objSelection.Find
.Text = txtBuscar
.Forward = True
.MatchWholeWord = True
.Wrap = wdFindContinue
.Format = False
.Replacement.Text = txtRemplazar
.Execute ,,,,,,,,,,wdReplaceAll
End With
oWord.ActiveDocument.Save
oWord.Quit
Set oWord = Nothing
End Function
Call ReemplazarText ("E: ootDocAD-OBRA-FOSEG-SINANTICIPO.doc", Request("txt1"), Request("txt2"))
end if
if err.number <> 0 then
response.Write(err.description)
response.End()
end if
%>
<form action="gamasp.asp" method="post">
<table>
<tr>
<td>Buscar:</td>
<td><input type="text" name="txt1" value="" /></td>
</tr>
<tr>
<td>Reemplazar con:</td>
<td><input type="text" name="txt2" value="" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Aceptar" /></td>
</tr>
</table>
</form>
Con este codigo logro remplazar el texto pero no asi los encabezados y pie de pagina, investigando encontre como poner texto pero no reemplazar.
Este es el codigo:
With oWord.ActiveDocument.Sections(1)
.Headers(wdHeaderFooterEvenPages).Range.Text = "cab"
.Footers(wdHeaderFooterEvenPages).Range.Text = "pie"
End With
Espero alguien me pueda ayudar, saludos.
Valora esta pregunta
0