Hi, my name is Sandra and I need help.
I have a database with a form that allows me to fill out a word sheet using bookmarks.
I have the following problem:
- I have a combo box with 2 value: Option1 and Option2;
- When I select Option1 then I need the following writing in bold centered text to appear in the Word sheet: "Lorem Ipsum etc...";
If I select Option 2 instead, nothing should appear
Can anyone help me?
Code:
Private Sub Comando171_Click()
Call ActivateWord
Call Avviso369
End Sub
Private Sub Avviso369()
Dim appword As Word.Application
Dim doc As Word.Document
Dim fPath As String
Dim FName As String
Dim ReplSel As Boolean
Dim i As Integer
On Error Resume Next
Set appword = GetObject(, "Word.Application")
Error.Clear
If Err.Number <> 0 Then
Set appword = CreateObject("Word.Application")
End If
On Error GoTo 0
fPath = "C:\415\Modelli\"
FName = "Avviso369.dotx"
appword.Visible = True
appword.Activate
ReplSel = appword.Options.ReplaceSelection
appword.Options.ReplaceSelection = True
Set doc = appword.Documents.Add(fPath & FName)
doc.Activate
If doc.Bookmarks.Exists(Tipo_Dif_Indag_1) Then
doc.Bookmarks("avviso369bis").Select
If doc.Bookmarks(Me.Tipo_Dif_Indag_1) = "Option1 " Then
appword.Selection.TypeText Me."Lorem Ipsum etc..."
Else
appword.Selection.TypeText ""
End If
End If
End Sub