Accessing ReplicationItem Objects

You access an existing ReplicationItem object by calling the ReplicationProject.EnumItems method, as in the following example, where ReplItem is the name you give to the ReplicationItem object:

Option Explicit 
On Error Resume Next

const OPEN_EXISTING_PROJECT  = 2
const CRS_ERROR_NO_MORE_ITEMS  = 0&80003B17

dim ReplServer
set ReplServer = CreateObject("Crsapi.ReplicationServer")
ReplServer.Initialize("")
dim ReplProject
set ReplProject = ReplServer.OpenProject("MyProject", OPEN_EXISTING_PROJECT)

Dim ReplItem
dim Iterator
Iterator = 0
dim ReplError

do while True
  'Clear any error text
  Err.Clear
  'Get the next replication item
  set ReplItem = ReplProject.EnumItems "\LocalProj", Iterator 

  'Display error message and quit if empty object returned
  if IsEmpty(ReplItem) then
    Wscript.Echo "Empty replication item returned."
    exit do
  end if

  'Quit if "No more items" error 
  ReplError = Err.Number
  if ReplError = CRS_ERROR_NO_MORE_ITEMS then exit do

  'Now you have a valid replication item
  'Use ReplicationClient to replicate it 
  ...

Loop

'Release objects
set ReplItem    = Nothing
set ReplProject = Nothing
set ReplServer  = Nothing

© 1997-1998 Microsoft Corporation. All rights reserved.