Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Web Part Error

  Asked By: Kelsey    Date: May 01    Category: Sharepoint    Views: 761

I keep receiving a "Script Execution Error: Object required" and I
can't figure out what's going on. My web part doesn't show up. Here's
the code: PLEASE HELP!!

' GetSortedFolderContent.vbs
' uses GetDocsArray function to return an Array of document names
' for a given SPS folder - this in turn calls SortStringArray sorts
' an array of strings in alpha order

Dim Doc
Dim nArray
Dim ReturnArray
Dim DataSourceName

' get args
Set WshShell = Wscript.CreateObject("Wscript.Shell")
set oArgs=Wscript.Arguments

' ie this is an error
If (oArgs.Count <> 1) Then
WScript.Echo "Usage : CSCRIPT GetSortedFolderContent.vbs "
WScript.Echo "i.e : CSCRIPT GetSortedFolderContent.vbs
DataSourceName = oArgs.Item(0)
End I

' get the array
ReturnArray = GetDocsArray(DataSourceName)

' Display each item in the array
For Each Doc in ReturnArray
WScript.Echo Doc

' Function GetDocsArray
' Returns an Array of docs in Alpha Order for a given folder
Function GetDocsArray(DataSourceName)
Dim oFolder
Dim RS
' create the array
Dim DocArray()
Dim Count

Count = 0

' create folder object
set oFolder = CreateObject("CDO.KnowledgeFolder")

' open the folfer
oFolder.DataSource.Open DataSourceName
' create recordset obj
set RS = CreateObject("ADODB.Recordset")

' create recordset of the folder items ie docs
set RS = oFolder.Items

' expand the array
Redim preserve DocArray(Count)
DocArray(Count) = RS.Fields ("RESOURCE_PARSENAME")
Count = Count + 1


' return a sorted version of the array
GetDocsArray = SortStringArray(DocArray)
End Function

' Function SortStringArray
' returns a variant / Array sorted in Alpha order
' Pinched from "A Better Shell Sort: Part I" from MSDN
Function SortStringArray(vArray)

Dim TempVal ' As Variant
Dim i ' As Long,
Dim GapSize ' As Long
Dim CurPos ' As Long
Dim FirstRow ' As Long
Dim LastRow ' as Long
Dim NumRows ' As Long

FirstRow = LBound(vArray)
LastRow = UBound(vArray)

NumRows = LastRow - FirstRow + 1
GapSize = GapSize * 3 + 1
Loop Until GapSize > NumRows
GapSize = GapSize \ 3
For i = (GapSize + FirstRow) To LastRow
CurPos = i
TempVal = vArray(i)
Do While CompareResult(vArray(CurPos - GapSize),TempVal)
vArray(CurPos) = vArray(CurPos - GapSize)
CurPos = CurPos - GapSize
If (CurPos - GapSize) < FirstRow Then Exit Do
vArray(CurPos) = TempVal
Loop Until GapSize = 1

SortStringArray = vArray
End Function

Private Function CompareResult(Value1, Value2)
CompareResult = (StrComp(Value1, Value2, vbTextCompare) = 1)
End Function



3 Answers Found

Answer #1    Answered By: Otis Blackwell     Answered On: May 01

This is not a web  part. Are you copying this into a web part? This needs
to be run from the command line. Is the problem?

Answer #2    Answered By: Virendar Chaudhari     Answered On: May 01

You're right, I'm trying to copy it into the web  part.

Answer #3    Answered By: Mitchel Villarreal     Answered On: May 01

fine for me running it from the command line - CSCRIPT

Didn't find what you were looking for? Find more on Web Part Error Or get search suggestion and latest updates.