Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

“.FileName”

Status
Not open for further replies.

johnmtb

Programmer
Jul 12, 2008
37
US
Dear All,

I cannot understand why the following code does not work, when a previous programme using the same code works perfectly.

I am trying to obtain the complete name of a file, when I know part of that name, the part that I know being 521026. The “*.*”, should provide the remainder of the file name, but all I get is “521026*.*”. Why?

This is the code:

Code:
With Application.FileSearch
     .LookIn = "C:\X\Finance\"
     .FileName = CellStatus & "*.*"
     If .Execute > 0 Then
          Call SetHyperlink
     Else
          GoTo LookAgain
     End If
End With

"C:\X\Finance\" is the folder, and CellStatus is read by another part of the programme. I am expecting the file name to be "521026 WT0841.pdf".

Regards,

john
 
Strongm,

i don't understand, the programme is written in VB6 not VBA. what i really need to know, is why the wildcards, "*", are not being expanded in this programme, but they are in my other programme.

regards,

john
 

But your code appears to be VBA code.
Whether or not this is written in a MS Office application or in the Visual Studio's Visual Basic 5 or 6 IDE with a MS Office reference and using a MS Office Application Object, it is still VBA code (unless some one has built code to mock VBA functionality)

Therefore, questions concerning VBA specific code, should be asked in the VBA forum which strongm directed you to.
 
Notwithstanding the advise aleady given; the FileSearch Object was withdrawn in VBA for Office 2007.
 
All,

thank you for your input.

the version of MS office that i am using is 2003, on both computers, but on one this works on the other it does not.

plus the programme runs in debug correctly, it just returns "521026*.*"., instead of "521026 WT0841.pdf".

it simply is not expanding the wild cards.

regards,

john
 
Could it be that the other program is exposing the FileSearch ojbect to a command shell?
 
Harebrain,

not that i know of, they are both operating under the same constraints.

regards,

john
 
John,

Did you TRY running th code that I posted in Forum707? And if so, what was the result?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

i thought that i had tried your code, but when i checked again, i realized that i had not.

i have now tried it, and it gives me the file i was looking for. thank you very much.

regards,

john
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top