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:
The one I'm having issues with is the
, 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.
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