problema con una macro usando excel + word

omegared6969

New Member
Joined
Feb 28, 2015
Messages
1
hola, se me presento el siguiente problema tratando de seguir una idea que vi en otra pagina:

tengo en excel una planilla de datos (calificaciones y otros datos de estudiantes) y en word una plantilla de informe de esas calificaciones, y mi intencion es poder crear de forma separada un informe para cada estudiante vinculando ambos archivos usando la macro que vi en esa pagina

la macro en cuestion:


wArch = Hoja1.Range("C3").Text & Hoja1.Range("C2").Text & ".dotx"


Set objWord = CreateObject("Word.Application")
objWord.Visible = True

objWord.documents.Add Template:=wArch, NewTemplate:=False, DocumentType:=0



For i = 1 To Hoja1.Range("c1").Value

datos = Hoja1.Range("B" & i).Text

reemp = Hoja1.Range("A" & i).Text



With objWord.Selection.Find
.Text = datos

.Replacement.Text = reemp

.Execute Replace:=2

End With
Next i
objWord.Activate


se supone que en el archivo excel tengo 2 hojas; una donde estan los datos y en la otra (una hoja auxiliar) estan los datos que utiliza la macro....el problema que tengo es que al momento de ejecutar la macro y ver si reemplaza los datos en la plantilla de word aparece un "error 5151" (obviamente no aparece el archivo de word) y si pulso depurar en la pantalla de error aparece marcada la linea de la macro que esta en rojo

alguna ayuda?? gracias de antemano
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,611
Messages
6,120,510
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top