I have managed to replace:
Code:
Application.Templates( _"L:\06. MODELOS DE DOCUMENTOS\01 ATESTADOS\ACCIDENTES DE CIRCULACIÓN\BAEI\Informe Tecnico\BAEI - INFORME TÉCNICO.dotm"). _
BuildingBlockEntries("INICIO Y EXPOSICION DE HECHOS").Insert Where:=Selection.Range, RichText _
:=True
by:
variable
Ruta in:
Code:
Application.Templates("Ruta"). _
BuildingBlockEntries("INICIO Y EXPOSICION DE HECHOS").Insert Where:=Selection.Range, RichText _
:=True
Using this simple code. Now I will upload more information on how I have organized the content blocks, etc.
Code:
Sub Ruta()
Dim InicioRuta As String
Dim FinalRuta As String
Dim Ruta As String
Dim NumeroAT As String
InicioRuta = "L:\02.- ATESTADOS 2022\ATESTADOS PAMPLONA\2. ACCIDENTES CIRCULACION"
FinalRuta = "BAEI – INFORME TECNICO.docm"
NumeroAT = "\AT-1234568\" 'Here I will create a dialog for the user to indicate what AT-xxxxxxx number is going to be given.
Ruta = InicioRuta + NumeroAT + FinalRuta
MsgBox Ruta 'It returns the path, so this works for now.
End Sub
Here, MsgBox Ruta, effectively returns the path but when putting this Ruta variable where I indicated above, it does not have the effect, but it does not give an error either.
I have tried to put the same path with and without variable. With no variable, BuildingBlockEntries("INICIO Y EXPOSICION DE HECHOS") is inserted. But with the variable Ruta, no.
Let me explain, this code:
Code:
Application.Templates( _"L:\06. MODELOS DE DOCUMENTOS\01 ATESTADOS\ACCIDENTES DE CIRCULACIÓN\BAEI\Informe Tecnico\BAEI - INFORME TÉCNICO.dotm"). _
BuildingBlockEntries("INICIO Y EXPOSICION DE HECHOS").Insert Where:=Selection.Range, RichText _
:=True
is the same as:
Code:
Application.Templates("Ruta"). _
BuildingBlockEntries("INICIO Y EXPOSICION DE HECHOS").Insert Where:=Selection.Range, RichText _
:=True
if in the Ruta macro I put these values:
Code:
Sub Ruta()
Dim InicioRuta As String
Dim FinalRuta As String
Dim Ruta As String
Dim NumeroAT As String
InicioRuta = "L:\06. MODELOS DE DOCUMENTOS\01 ATESTADOS\ACCIDENTES DE CIRCULACIÓN\BAEI"
FinalRuta = "BAEI – INFORME TECNICO.docm"
NumeroAT = "\Informe Tecnico\" 'Here I will create a dialog for the user to indicate what AT-xxxxxxx number is going to be given.
Ruta = InicioRuta + NumeroAT + FinalRuta
MsgBox Ruta 'It returns the path, so this works for now. The message returns L:\06. MODELOS DE DOCUMENTOS\01 ATESTADOS\ACCIDENTES DE CIRCULACIÓN\BAEI\Informe Tecnico\BAEI - INFORME TÉCNICO.dotm
End Sub
This doesn't give an error, but it doesn't do anything. HELP
Code:
Application.Templates("Ruta"). _
BuildingBlockEntries("INICIO Y EXPOSICION DE HECHOS").Insert Where:=Selection.Range, RichText _
:=True
We are close to getting it