Consulting

Results 1 to 3 of 3

Thread: Solved: sending data from form to doc

  1. #1
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location

    Solved: sending data from form to doc

    I have the following vb and don't see why it's not working.

    Now i am running this in Word.

    [vba]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[/vba]

    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"
    Last edited by Emoncada; 12-29-2009 at 08:49 AM.

  2. #2
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Ok by looking at it, it must be because I never set wd.
    How can I word it to set wd active document?

  3. #3
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    I figured it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •