B
Brian Lukanic
What's the best way to determine if a specific filename on the server exists?
If it does exist, loop to next. (I am reading and parsing a CSV.) If not
exist, then save a file onto the the server with the filename as parsed from
the CSV.
My script below works great to create initial records. But my CSV file grows
with new additions mixed througout. I'd like my script to include
functionality that skips a record of the "filenametocreate" already exists on
the server.
Sub CreateClientRecords()
Dim sLayout, sTemp As String
Dim Value$, j As Integer
Open "C:\data\MyText2.txt" For Input As #2
Do While Not EOF(2)
Line Input #2, Value$
sTemp = Value$
sLayout = Split(sTemp, ",")
For j = 0 To UBound(sLayout)
s1 = sLayout(0)
s2 = sLayout(1)
' MsgBox sLayout(j)
Next j
'This is the project build phase
'FileOpenEx Name:="<>\zclient Workspace", ReadOnly:=False
' These commands fill in the required Project-level fields
ActiveProject.ProjectSummaryTask.SetField _
FieldNameToFieldConstant("Client ID"), s1
ActiveProject.ProjectSummaryTask.SetField _
FieldNameToFieldConstant("Zone"), s2
ActiveProject.ProjectSummaryTask.SetField _
FieldNameToFieldConstant("Portfolio Comments"), "Client Record created
by the loader."
FileSaveAs Name:="<>\Z-Client Workspace - " & s1, FormatID:=""
PauseIt 10
FileSave
PauseIt 5
Loop
Close 2
FileCloseEx pjSave, True, True
Dim sLayout2, sTemp2 As String
'Dim Value$, j As Integer
Open "C:\data\MyText2.txt" For Input As #2
Do While Not EOF(2)
Line Input #2, Value$
sTemp2 = Value$
sLayout2 = Split(sTemp2, ",")
For j = 0 To UBound(sLayout2)
s1 = sLayout2(0)
s2 = sLayout2(1)
' MsgBox sLayout2(j)
Next j
DisplayAlerts = False
FileOpenEx Name:="<>\Z-Client Workspace - " & s1, ReadOnly:=False
publish Republish:=Null, WssURL:="http://epm.csstarsit.com/PWA/" & s1
PauseIt 300
DisplayAlerts = True
FileCloseEx pjSave, True, True
PauseIt 10
Loop
Close 2
End Sub
Function PauseIt(NumOfSeconds As Integer) As Boolean
Dim dStart As Date
dStart = Now
Do
DoEvents
Loop Until DateAdd("s", NumOfSeconds, dStart) <= Now
End Function
If it does exist, loop to next. (I am reading and parsing a CSV.) If not
exist, then save a file onto the the server with the filename as parsed from
the CSV.
My script below works great to create initial records. But my CSV file grows
with new additions mixed througout. I'd like my script to include
functionality that skips a record of the "filenametocreate" already exists on
the server.
Sub CreateClientRecords()
Dim sLayout, sTemp As String
Dim Value$, j As Integer
Open "C:\data\MyText2.txt" For Input As #2
Do While Not EOF(2)
Line Input #2, Value$
sTemp = Value$
sLayout = Split(sTemp, ",")
For j = 0 To UBound(sLayout)
s1 = sLayout(0)
s2 = sLayout(1)
' MsgBox sLayout(j)
Next j
'This is the project build phase
'FileOpenEx Name:="<>\zclient Workspace", ReadOnly:=False
' These commands fill in the required Project-level fields
ActiveProject.ProjectSummaryTask.SetField _
FieldNameToFieldConstant("Client ID"), s1
ActiveProject.ProjectSummaryTask.SetField _
FieldNameToFieldConstant("Zone"), s2
ActiveProject.ProjectSummaryTask.SetField _
FieldNameToFieldConstant("Portfolio Comments"), "Client Record created
by the loader."
FileSaveAs Name:="<>\Z-Client Workspace - " & s1, FormatID:=""
PauseIt 10
FileSave
PauseIt 5
Loop
Close 2
FileCloseEx pjSave, True, True
Dim sLayout2, sTemp2 As String
'Dim Value$, j As Integer
Open "C:\data\MyText2.txt" For Input As #2
Do While Not EOF(2)
Line Input #2, Value$
sTemp2 = Value$
sLayout2 = Split(sTemp2, ",")
For j = 0 To UBound(sLayout2)
s1 = sLayout2(0)
s2 = sLayout2(1)
' MsgBox sLayout2(j)
Next j
DisplayAlerts = False
FileOpenEx Name:="<>\Z-Client Workspace - " & s1, ReadOnly:=False
publish Republish:=Null, WssURL:="http://epm.csstarsit.com/PWA/" & s1
PauseIt 300
DisplayAlerts = True
FileCloseEx pjSave, True, True
PauseIt 10
Loop
Close 2
End Sub
Function PauseIt(NumOfSeconds As Integer) As Boolean
Dim dStart As Date
dStart = Now
Do
DoEvents
Loop Until DateAdd("s", NumOfSeconds, dStart) <= Now
End Function