Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Actualizar un content control text

publicado

Hola a todos¡ Quiero actualizar el contenido de una Content Control Text tras abrir el archivo, tal que así:

Sub Sample()

'Ubicación y nombre de la plantilla

Dim wArch As String

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

'Con la variable siguiente definimos que vamos a trabajar con un documento de Word.

Set objWord = CreateObject("Word.Application")

objWord.Visible = True

'Abrimos el documento

objWord.Documents.Open wArch

'Introducir un nuevo texto en el cuadro

Dim cc As ContentControl

For Each cc In ActiveDocument.ContentControls

If cc.Title = "Text1" Then

cc.Range.Text = "Hello World!"

Exit For

End If

Next cc

End Sub

Sin embargo, me dice que debo definir "cc" . ¿Podríais ayudarme?

Muchas gracias de antemano

Featured Replies

publicado
  • Autor

He probado la parte del código "Dim cc As ContentControl..." en una macro en word y funciona. Entonces, creo que el problema está en que no conecta bien el documento que abre con la parte que asigna texto a los cuadros de texto. ¿qué opináis?

----------------------------------------------------------------------------------------------------------------------

Sub Sample()

'Ubicación y nombre de la plantilla

Dim wArch As String

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

'Con la variable siguiente definimos que vamos a trabajar con un documento de Word.

Set objWord = CreateObject("Word.Application")

objWord.Visible = True

'Abrimos el documento

objWord.Documents.Open wArch

objWord.Activate

Dim cc As ContentControl

For Each cc In objWord.Selection.ContentControls

If cc.Title = "Text1" Then

cc.Range.Text = "Hello World!"

Exit For

End If

Next cc

End Sub

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.