|
-
Jan 13th, 2010, 05:03 AM
#1
Thread Starter
Lively Member
[RESOLVED] IF Statements
Hi All,
I'm having trouble trying to omit some user folder off of a script we use to distribute file to all staff.
The below script is used to distribute a single database to multiple folders which users here store their files and such.
I need to omit some users from receiving this new file as their systems haven't been upgraded.
So far I have only added:
Code:
If InStr(f1.Name, "Dobbs, Terry" & "Seacole, Steve" & "Patel, Ash" & "Jenkins, Tricia") = ture Then
Resume Next
End If
But it doesn't like it, Any help would be greatly appriciated.
Code:
Dim fso, f, fc, f1, SourceFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set SourceFile = fso.GetFile("H:\K Drive\Databases\NewLiveActs.mde")
Set f = fso.GetFolder("H:\K Drive\")
Set fc = f.SubFolders
For Each f1 In fc
If InStr(f1.Name, ",") > 0 Then
On Error Resume Next
SourceFile.Copy f1 & "\Databases\"
If Err.Number <> 0 Then
Select Case Err.Number ' Evaluate error number.
Case 70
mystr = mystr & f1 & " - Permission Denied" & vbNewLine 'add to string here
Case 76
mystr = mystr & f1 & " - Path not found" & vbNewLine ' add to string here
Err.Clear
Case Else
End Select
Else
End If
On Error GoTo 0
End If
If InStr(f1.Name, "Dobbs, Terry" & "Seacole, Steve" & "Patel, Ash" & "Jenkins, Tricia") = ture Then
Resume Next
End If
Next
mystr = mystr & " -- File Distribution Completed -- " & vbNewLine
Set f1 = fso.CreateTextFile("H:\K Drive\NewLiveactsScriptLog.txt", True)
f1.Write mystr
f1.Close
Set f1 = Nothing
Set fso = Nothing
Last edited by Kubull; Jan 13th, 2010 at 06:17 AM.
-
Jan 13th, 2010, 06:08 AM
#2
Re: IF Statements
Try this
Code:
If InStr(f1.Name, "Dobbs, Terry") Or _
InStr(f1.Name, "Seacole, Steve") Or _
InStr(f1.Name, "Patel, Ash") Or _
InStr(f1.Name, "Jenkins, Tricia") Then
'~~> For Testing
MsgBox "Hello"
End If
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jan 13th, 2010, 06:33 AM
#3
Thread Starter
Lively Member
Re: IF Statements
Thanks Coolsid,
The msgbox comes up, how would I now get the script to skip them? not sure resume next does the job.
-
Jan 13th, 2010, 06:42 AM
#4
Re: IF Statements
Code:
Dim fso, fo, sf, fi, ErrStr, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set fi = fso.GetFile("H:\K Drive\Databases\NewLiveActs.mde")
Set fo = fso.GetFolder("H:\K Drive\")
ErrStr = ""
For Each sf In fo.SubFolders
If InStr(sf.Name, ",") > 0 Then
Select Case sf.Name
Case "Dobbs, Terry"
Case "Seacole, Steve"
Case "Patel, Ash"
Case "Jenkins, Tricia"
Case Else
On Error Resume Next
fi.Copy sf.Path & "\Databases\"
If Err.Number <> 0 Then
ErrStr = ErrStr & sf.Name & " - " & Err.Description & vbNewLine
Err.Clear
End If
On Error GoTo 0
End Select
End If
Next
If ErrStr <> "" Then MsgBox ErrStr
-
Jan 13th, 2010, 07:02 AM
#5
Thread Starter
Lively Member
Re: IF Statements
Awsome Works like a charm! many thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|