View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Dir function error

You might try storing all the filenames in an array by iterating Dir loop
without doing anything else in it (except saving the filenames to the array)
and then in your current Dir iteration loop, iterate the array elements
instead.

--
Rick (MVP - Excel)


"BigJimmer" wrote in message
...
No, there is no other Dir within the other code not shown (that was
something
I did think of after I posted originally).

I have found a statement I recently added to my code that is causing the
Dir
function to be reset, though I'm not sure why.

The function that causes this is from Chip Pearson's website
(http://www.cpearson.com/Excel/docprop.aspx) -

Function GetProperty(PropertyName As String, PropertySet As
PropertyLocation, _
Optional WhatWorkbook As Workbook) As Variant
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''
' GetProperty
' This procedure returns the value of a DocumentProperty named in
' PropertyName. It will examine BuiltinDocumentProperties,
' or CustomDocumentProperties, or both.

This function works as intended, and the resetting of the value of Dir is
the only dowside for my particular purpose.



"Rick Rothstein" wrote:

I cannot duplicate your problem... the code you posted works fine. Are
you
by any chance using another Dir command (with a different argument) in
the
section you designated "additional logic here"?

--
Rick (MVP - Excel)


"BigJimmer" wrote in message
...
I have the following code...

Dim fName As String
dim DestPath as string

DestPath = ThisWorkbook.Path & "\"
fName = Dir(DestPath & "*.*")
Do Until fName = vbNullString

'additional logic here

fName = Dir
Loop

I get error 5 Invalid procedure call or argument on the line fname =
Dir
and
don't understand why.

I am using Excel 2000.

Thanks!


.