Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jan 2001
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dealing with spaces in field names

    I am writing a script to print to a Word template from a custom outlook 2000 form. Everything works just fine when the fields I'm pulling data from have no spaces in them, but some Outlook's pre-defined fields have spaces (like "Mailing Address"). When I put these field names into the script it chokes and I get a runtime error.

    Has anyone dealt with this before? Should I just create my own [spaceless] fields to work around this?

    This script is shown below.

    Thanks,

    Mary

    Sub cmdPrint_Click()
    Dim objWord
    Dim objDoc
    On Error Resume Next
    Set objWord = GetObject(, Word.Application)
    If objWord Is Nothing Then
    Set objWord = CreateObject("Word.Application")
    End If
    On Error GoTo 0
    objWord.Visible = True
    Set objDoc = objWord.Documents.Add("Cocuments and SettingsmreillyApplication DataMicrosoftTemplatestest.dot")
    Call AddTRData(objDoc)
    Set objDoc = Nothing
    Set objWord = Nothing
    End Sub

    Sub AddTRData(objDoc)
    Dim strValue
    objDoc.FormFields("Company").Result = _
    Item.UserProperties("Company").Value
    objDoc.FormFields("NCmanage").Result = _
    Item.UserProperties("NCmanage").Value
    objDoc.FormFields("CEO").Result = _
    Item.UserProperties("CEO").Value
    objDoc.PrintOut
    End Sub

  2. #2
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Roanoke area, Virginia, USA
    Posts
    3,729
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dealing with spaces in field names

    does the html trick of work where spaces belong work?

  3. #3
    Lounger
    Join Date
    Jan 2001
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dealing with spaces in field names

    I'm not sure I understand. Do you mean using "&nbsp"? I'll try and let you know.

  4. #4
    Lounger
    Join Date
    Jan 2001
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dealing with spaces in field names

    Wow - just at looked at my previous post - the markup was removed.

    I tried using "& n b s p" (spaces removed) where the space would go and it didn't work. Also, to add to the fun - the Word template I'm printing to is using form fields and they don't accept spaces in field names either. I think I may just need to rename all my "spacey" field names.

    Argh,

    Mary

Posting Permissions

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