256 Caracters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • natural
    New Member
    • Aug 2007
    • 21

    #1

    256 Caracters

    Good Day.

    I am currently via Form send data to a word template..
    I have about 150 bookmarks in a word document which was previously imported via a simular document. and appended into my DB. The data changes etc we export it back for various reasons.

    I use the following

    Code:
    --------------------------------------------------------------------------------

    Private Sub ExportPDForm_Cl ick()
    Dim wrdApp As Object
    Dim wrdDoc As Object
    Set wrdApp = CreateObject("W ord.Application ")
    Set wrdDoc = wrdApp.Document s.Add(CurrentPr oject.Path & "\Personal Data Form.dot")
    With wrdDoc
    .FormFields("Ti tle").Result = Me.Form.Title
    .FormFields("Fi rstName").Resul t = Me.Form.[First Name]
    .FormFields("Ad dInfo1").Result = Me.Form.[Add Information1]
    .FormFields("Ad dInfo2").Result = Me.Form.[Additional Information2]
    .FormFields("Su mmCivSkills1"). Result = Me.Form.[Summary Civ Skills1]
    .FormFields("Su mmCivSkills2"). Result = Me.Form.[Summary Civ Skills2]
    .FormFields("Su mmMilSkills1"). Result = Me.Form.[Summary Mil Skills1]
    .FormFields("Su mmMilSkills2"). Result = Me.Form.[Summary Mil Skills2]
    .FormFields("Su mmCompSkills1") .Result = Me.Form.[Computer Skills1]
    .FormFields("Su mmCompSkills2") .Result = Me.Form.[Computer Skills2] etc etch... + 150 records
    End With
    wrdDoc.SaveAs gcPDExportPath & ID
    wrdApp.Visible = TrueEnd Sub
    --------------------------------------------------------------------------------


    Due to the fact that some of the data in my DB is in a memo field ( The fields listed in blue ) Consist of more than 256 caracters i get a string to long error.

    I then search the internet and found the following from a MPV website on how to by pass it.

    Code:
    --------------------------------------------------------------------------------

    If you use:

    Dim FmFld As FormField,
    Str1 As StringStr1 = (a long string > 256 characters)
    Set FmFld = ActiveDocument. FormFields(1)
    FmFld.Result = Str1

    You get an error: “String too long” (a ridiculous “design” feature, given that you can do it manually without problems!).Same if you use:

    ActiveDocument. Formfields("Tex t1").Result = Str1
    You can get round this by using:
    ActiveDocument. UnprotectFmFld. Range.Fields(1)
    .Result.Text = Str1ActiveDocum ent.Protect Type:=wdAllowOn lyFormFields, NoReset:=True

    Or if you're referring to the formfield by name:ActiveDocu ment.UnprotectA ctiveDocument.B ookmarks("Text1 ").Range.Fields (1).Result.Text = Str1ActiveDocum ent.Protect Type:=wdAllowOn lyFormFields, NoReset:=True
    --------------------------------------------------------------------------------


    Now i have tried various ways to try and change my current code to make use of the above code. But Removed the to unprotect Document/ protect doc due to the fact that it would replace my bookmarks for later use.

    I was hoping someone could perhaps assist in how i could amend the above mentioned. To allow the insert of records more than 256 caracters. Since the ways i have tried still gives me my String To long Error. Any advise would be apreciated.

    Kind Regards
    Sn
    Last edited by natural; Aug 29 '07, 10:53 AM. Reason: Incorrect
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hi, there.

    FormField.Resul t property is String type, here is nothing to do from Access side. Try to drop a value to FormField.Range . Use it for memo fields only as soon as the operation destroys field.
    Code:
    .FormFields("Title").Range = Me.Form.Title

    Comment

    Working...