| |
markmcrobie
Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
|
Ok, with a slight modification of the example above, I got it working within my script. However it was complete luck/trial & error and I really don't understand how it's working. I'm not happy with this, as I see no value in getting someone else's code to work without understanding how it works myself. So could someone please explain how the following code works, in the context of my original problem. About all I understand is the Len(strResult)-1 statement is to strip off the trailing "-". Many thanks, I'm keen to learn! Code: strSystemMsg = "Please enter System for: " & VbCRLf & VbCRLf & strNewName & strExtension & VbCRLf & VbCRLf &_ "Hummingbird Doc #: " & strDocNo & VbCRLf & VBCRLf & "To omit the System, click Cancel" arrSysSeqRev(0) = InputBox(strSystemMsg,strTitle,"", 100, 100) strSequenceMsg = "Please enter Sequence Number for: " & VbCRLf & VbCRLf & strNewName & strExtension & VbCRLf & VbCRLf &_ "Hummingbird Doc #: " & strDocNo & VbCRLf & VbCRLf & "To omit the Sequence Number, click Cancel" arrSysSeqRev(1) = InputBox(strSequenceMsg,strTitle,"", 100, 100) strRevisionMsg = "Please enter Revision for: " & VbCRLf & VbCRLf & strNewName & strExtension & VbCRLf & VbCRLf &_ "Hummingbird Doc #: " & strDocNo & VbCRLf & VbCRLf & "To omit the Revision, click Cancel" arrSysSeqRev(2) = InputBox(strRevisionMsg,strTitle,"", 100, 100) For Each strSSR In arrSysSeqRev If strSSR <> "" Then strResult = strResult & strSSR & "-" End If Next If strResult <> "" Then strResult = Left(strResult, Len(strResult)-1) 'Append the user's input to the beginning of the new file name and actually rename the file. 'Will append a number to the end of any file name if it causes a duplicate of another file that's been renamed. If strResult = "" Then If fso.FileExists(strNewName & strExtension) Then intCounter = intCounter + 1 File.Name = strNewName & intCounter & strExtension Else File.Name = strNewName & strExtension End If Else If fso.FileExists(strResult & " - " & strNewName & strExtension) Then intCounter = intCounter + 1 File.Name = strResult & " - " & strNewName & intCounter & strExtension Else File.Name = strResult & " - " & strNewName & strExtension End If End If
|
|