Emoncada
12-29-2009, 08:26 AM
I have the following vb and don't see why it's not working.
Now i am running this in Word.
Private Sub CmdButtonDone_Click()
Dim wd As Object, wdApp As Object
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
With wd
.FormFields("SVNAME1").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME2").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME3").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME4").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME5").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME6").Result = ServerNameForm.TxtServerName.Value
.FormFields("BRNAME1").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME2").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME3").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME4").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME5").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME6").Result = SiteNameForm.TxtSiteName.Value
End With
SiteNameForm.Hide
End Sub
Can anyone see what's missing?
It's giving me a Run-time error '91':
Object variable or With Block variable not set
Highlights ".FormFields("SVNAME1") = ServerNameForm.TxtServerName.Value"
Now i am running this in Word.
Private Sub CmdButtonDone_Click()
Dim wd As Object, wdApp As Object
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
With wd
.FormFields("SVNAME1").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME2").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME3").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME4").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME5").Result = ServerNameForm.TxtServerName.Value
.FormFields("SVNAME6").Result = ServerNameForm.TxtServerName.Value
.FormFields("BRNAME1").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME2").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME3").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME4").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME5").Result = SiteNameForm.TxtSiteName.Value
.FormFields("BRNAME6").Result = SiteNameForm.TxtSiteName.Value
End With
SiteNameForm.Hide
End Sub
Can anyone see what's missing?
It's giving me a Run-time error '91':
Object variable or With Block variable not set
Highlights ".FormFields("SVNAME1") = ServerNameForm.TxtServerName.Value"