Results 1 to 5 of 5
  1. #1
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: script error at setting a range (OL >> Word) (Eng./OL2002, WD2002)

    Try removing the named arguments Start:= and End:=. I believe that VBS doesn't support named arguments, relying instead solely on argument position, and perhaps "doesn't support" means "cannot handle."

  2. #2
    New Lounger
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: script error at setting a range (OL >> Word) (Eng./OL2002, WD2002)

    Jefferson, I think this is exactly it. No error now, and I can proceed with getting my code straightened out to do what I want it to... Thanks a bunch! (Amazing how easy it can be to help a relative newbie, ain't it?) Have a good weekend,

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: script error at setting a range (OL >> Word) (Eng./OL2002, WD2002)

    Abe,

    Just regarding getting your posted code to indent, you can do this by using [ pre ] and [ /pre ] tags (spaces added in this example so they will display).

    Gary

  4. #4
    New Lounger
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script error at setting a range (OL >> Word) (Eng./OL2002, WD2002)

    I'm trying to pass data from a selection of contacts to Word for custom formatting and printing. Contact data for each item is passed to Word through a subroutine, and I then try to set a Range for the next step. Problem is that I get a script error upon opening the form at the point where I try to set a range to the first entry--says it "Expected ')'". I've marked the line with "***" in the left margin (well, since this forum strips the indents there isn't really a margin!). I borrowed the format of this item from the W2002 VBA help entry "Range Object"--does something have to be changed for it to be acceptable in VBS? I tried putting it all in one long line without wrap, but that didn't help. Help!! Tips on making my code more efficient (or correct) will also be appreciated. Thanks! Hope my code is understandable without the structure.

    Abe

    <pre>Sub cmdPrintClassList_Click()
    Dim objWord
    Dim objDoc
    Dim strCurrSec
    Dim CurrFolder
    Dim AllItems
    Dim strFilter
    Dim ClassMembers
    Dim RgEntry
    Dim RgWhole
    Dim I

    strCurrSec = Item.UserProperties("StudentClassSection").Value
    If strCurrSec <> "None" And strCurrSec <> "Change" Then
    Set CurrFolder = Item.Parent
    Set AllItems = CurrFolder.Items
    strFilter = "[StudentClassSection] = " & Chr(34) & strCurrSec & Chr(34)
    Set ClassMembers = AllItems.Restrict(strFilter)
    ClassMembers.Sort "[LastName]", False 'sort class by last name

    'create Word doc and get ready to process
    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
    On Error Resume Next
    Set objDoc = objWord.Documents.Add("ClassList.dot")
    If objDoc Is Nothing Then
    intR = MsgBox("Could not create document." & Chr(13) & _
    "Template may be missing from Word Templates folder.", _
    48, "Could Not Create Document")
    Else 'begin processing members
    For Each Member In ClassMembers
    Set RgWhole = objDoc.Range
    Call SendStudentDataToClassListDoc(objDoc)

    'collect the first (updating) entry to copy to end
    Set RgEntry = objDoc.Range( _
    *** Start:=objDoc.Paragraphs(2).Range.Start, _
    End:=objDoc.Paragraphs(8).Range.End)

    'copy to the end
    RgWhole.Collapse wdCollapseEnd
    RgWhole.FormattedText = RgEntry.FormattedText
    Next

    'Move final addition to end
    Set RgEntry = objDoc.Range( _
    *** Start:=objDoc.Paragraphs(2).Range.Start, _
    End:=objDoc.Paragraphs(7).Range.End)
    RgWhole.Collapse wdCollapseEnd
    RgWhole.FormattedText = RgEntry.FormattedText
    RgEntry.Delete

    'Insert class section info at beginning
    Set RgWhole = objDoc.Range
    RgWhole.InsertBefore strCurrSec
    End If
    Else
    intR = MsgBox("Please try again with a member of a class.", _
    0, "Invalid Class Section")
    End If
    Set objDoc = Nothing
    Set objWord = Nothing
    Set strCurrSec = Nothing
    Set CurrFolder = Nothing
    Set AllItems = Nothing
    Set strFilter = Nothing
    Set ClassMembers = Nothing
    Set RgEntry = Nothing
    Set RgWhole = Nothing
    End Sub
    </pre>


    "pre" tags added, as per Gary Frieder's suggestion- Mod

  5. #5
    New Lounger
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: script error at setting a range (OL >> Word) (Eng./OL2002, WD2002)

    Thanks for the tip, Gary. I took a look at the source code to see how the moderator used it (thanks, whichever of you four stepped in), and will endeavor to do this next time.

Posting Permissions

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