Passing Excel Userform String to a Word Form Template to print out

jdr360

New Member
Joined
Nov 12, 2017
Messages
18
I really need help with this one, I have run into the 255 char limit of passing a string from excel to word. The following is what I have attached to the print command:

Code:
Private Sub cmdPrint_Click()


    Dim wdApp As Object, wd As Object, ac As Range
    On Error Resume Next
    Set wdApp = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
        Set wdApp = CreateObject("Word.Application")
    End If
    On Error GoTo 0
   
    Set wd = wdApp.Documents.Open(ActiveWorkbook.Path & "\MRC Alarm Response Sheet.dotm")
   
    wdApp.Visible = True
    Set ac = ActiveCell
    
    With wd
        .FormFields("wRCD").Result = Me.rcd.Value
        .FormFields("wTB").Result = Me.txtTakenBy.Value
        .FormFields("wDI").Result = Me.txtDateIn.Value
        .FormFields("wTI").Result = Me.txtTimeIn.Value
        .FormFields("wACN").Result = Me.cmbACN.Value
        .FormFields("wPOPC").Result = Me.txtPOPC.Value
        .FormFields("wAA").Result = Me.txtAA.Value
        .FormFields("wO").Result = Me.txtON.Value
        .FormFields("wZ").Result = Me.txtAZ.Value
        .FormFields("wPC").Result = PC
        .FormFields("wKHC").Result = KHC
        .FormFields("wD").Result = Me.cmbD.Value
        .FormFields("wTA").Result = Me.txtAT.Value
        .FormFields("wAL").Result = Me.txtAL.Value
        .FormFields("wCSN").Result = Me.txtCSN.Value
        .FormFields("wCBN").Result = Me.txtCBNumber.Value
        .FormFields("w3PAC").Result = Me.txt3PAC.Value
        .FormFields("w3PCB").Result = Me.txt3PCB.Value
        .FormFields("wAT").Result = Me.txtAT.Value
        .FormFields("wCT").Result = Me.txtCT.Value
        .FormFields("wCBT").Result = Me.txtBT.Value
        .FormFields("wCB").Result = Me.txtCB.Value
        .FormFields("wCanB").Result = Me.txtCB.Value
        .FormFields("wCanC").Result = Me.txtCC.Value
        .FormFields("wCanT").Result = Me.txtCT.Value
        .FormFields("wEPO").Result = Me.txtEPON.Value
        .FormFields("wRD").Result = Me.txtRD.Value
        '.FormFields("wERD").Result = Me.txtERD.Value
        .FormFields("wBT").Result = Me.cmbBT.Value
        .FormFields("wAD").Result = Me.txtDI.Value
        '.FormFields("wCN").Result = Me.txtCN.Value
    End With
  
    Set wd = Nothing
    Set wpapp = Nothing


End Sub

The one I'm having issues with is the
Code:
.FormFields("wRD").Result = Me.txtRD.Value
, I'm getting the "Run-time error '4609': String too long" error. There is one entry in my database I know is well over 255 chars (551 chars to be exact). I know a string can be more than 255 chars in Excel, just not sure how I can pass it into Word. Stumped on this one. Need someones help with this.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Anyone able to help with this? I've been stuck for many weeks now. I just can't get this to insert a large (more than 255 char) excel textbox into a word template formfield.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top