Hi guys ik hope you can help me i am new to VBA. I searched the internet for how to do if .. then otherwise if...
But i can't find the right way to do
What is want is: When cell A3 = 2 then find <<>> in word and paste text. But when A3 is 1 or three i want vba to paste another text in another cell.
i hope you can help me with it.
My is:
Option Explicit
Private Sub CommandButton1_Click()
Dim wApp As Word.Application
Dim myFile
Dim wDoc As Word.Document
myFile = Application.GetOpenFilename("Word Files (*.doc*), *.doc*")
If VarType(myFile) = vbBoolean Then Exit Sub
If Not myFile Like "*.doc*" Then Exit Sub
Set wApp = New Word.Application
wApp.Visible = True
Set wDoc = wApp.Documents.Open(myFile)
If Range("A3") = 2 Then
End If
With wDoc.Application.Selection
.Find.Text = "<<A1>>"
If .Find.Execute Then
.Text = Range("C4")
.EndOf wdWord, wdMove
End If
If Range("A3") = 3 Then
End If
With wDoc.Application.Selection
.Find.Text = "<<A2>>"
If .Find.Execute Then
.Text = Range("C8")
.EndOf wdWord, wdMove
End If
End With
End With
End Sub