PDA

View Full Version : Dir Run-time error



msretenovic
2004-11-02, 03:11 PM
Hello all,

I have a problem that I don't understand :confused: . I have the following code:



Private Function MKSiProcessDir(strDir As String, strFunc As String, Optional strVar As String)
Dim strDwg As String

strDwg = Dir(strDir & "*.dwg", vbNormal)
Do While strDwg <> ""
If (GetAttr(strDir & strDwg) And vbNormal) = vbNormal Then
If strFunc = "title" Then
Call MKSxHBTitleSub(strDir & strDwg)
ElseIf strFunc = "index" Then
Call MKSxHBIndexSub(strDir & strDwg)
ElseIf strFunc = "update" Then
Call MKSxHBUpdateBatchSub(strDir & strDwg)
ElseIf strFunc = "rdate" Then
Call MKSxHBRDateSub(strDir & strDwg, strVar)
ElseIf strFunc = "plot" Then
Call MKSxHBBatchPlotSub(strDir & strDwg)
ElseIf strFunc = "block" Then
Call MKSxBlockUpdateSub(strDir & strDwg, strVar)
ElseIf strFunc = "replace" Then
Call MKSxReplaceBlocksSub(strDir & strDwg)
End If
End If
strDwg = Dir '<-Error happens here
Loop
End Function

When I use the following is when I get the error:

Call MKSiProcessDir(strDirDwgs, "block", strDirBlock)

I have similar code elsewhere in my routine. But I do not get the error with those calls. It only happens when I pass "block" in as the second argument :banghead:. The error that I get is this:

Run-time error '5':

Invalid procedure call or argument

Can anybody shed a little light on this.

TIA,

chatcher
2004-11-02, 09:16 PM
The only thing I could think of is maybe your function for the 'block' method is pushing the Dir function.

msretenovic
2004-11-02, 09:26 PM
Yep, that was it. I have re-written it to avoid that situation. Thank you so much! :Puffy:

Have a good one! :beer: