[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Run-time Error 52 When Clicking on Registered File Type to Start App

Posted on 2004-10-22
13
Medium Priority
?
177 Views
Last Modified: 2010-05-02
I have an application that keeps giving the following error on all machines other than my development machine when I click on my app's registered file type.

Run-time error 52: Bad file name or number

Clicking on the registered file type on the machine app was developed on works fine. However, on all other machines where program was installed it gives me the run-time error 52 when clicking on the registered file type. If I open the file within my app, I don't get the error on the other machines.

Any suggestions?
0
Comment
Question by:abnc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12381105
If you are using Command$ , have you tried compiling a message box in to test the value of Command$ on one of the other machines?
0
 

Author Comment

by:abnc
ID: 12381478
I placed a msgbox to return the command$ value on the other machines and I get the full path and file name of the file that was clicked on. So that appears to be ok.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12381558
Are you using FreeFile to get a file number? If so,make sure the integer is being set to a valid file #.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:vinnyd79
ID: 12381585
Actually that would cause a problem on the development machine as well.
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 750 total points
ID: 12381614
Do the files have spaces in the name? If so,try enclosing the filename in qoutes:

Chr$(34) & Command$ & Chr$(34)
0
 

Author Comment

by:abnc
ID: 12381743
I am using FreeFile to get file number. If I trying the Chr$(34) that gives me a Path not found error on development machine, and on the other machines, I still get the 52 error bad file name or number.

Again, the problem only happens when I click on the registered file type. If I start the app first and then open the file, the problem does not occur.

The actual code block where the error is raised appears to be in this code below:

   Dim sTemp As String, intFileNum as Integer, intTotalCount as Integer
   intFileNum = FreeFile
   Open gstrFileName For Input As #intFileNum
   While Not EOF(intFileNum)
   Line Input #intFileNum, sTemp
   intTotalCount = intTotalCount + 1
   ReDim Preserve g_arrPhotos(intTotalCount)
   g_arrPhotos(intTotalCount - 1) = sTemp
   Wend
   Close
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12381924
>>when I click on the registered file type

Is it binary format?
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 12381992
Strange, does your file type have muliple actions set? Is "open" set as the default?
0
 

Author Comment

by:abnc
ID: 12381997
File being opened is a simple text file that can be opened with Notepad.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12382061
do

msgbox gstrFileName

and what is this?
0
 

Author Comment

by:abnc
ID: 12382138
I solved the problem, or at least it is working.

gstrFileName was my variable that would grab the Command$ value whenever Command$ has a value. However, there would be quotes (Chr(34)) surrounding the file path and name. For example, "c:\My Documents\Spain Trip.sld" and this caused the Bad File Name or Number error.

When I stripped the quotes off so that gstrFileName would be just c:\My Documents\Spain Trip.sld, with no quotes, then it worked just fine.

Make sense?
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12382291
This error can be raised if the file name has illegal characters in it:

gstrFileName = "/c:\testit.dat" '<<error 52

And of course always check if the file exists before opening it...

If FileExists(gstrFileName) Then
    'Open file
Else
    MsgBox gstrFileName & " does not exist"
End If

The FileExists function can be found here:
http://vbnet.mvps.org/index.html?code/fileapi/fileexists.htm

Good Luck!
0
 

Author Comment

by:abnc
ID: 12388224
I have awarded the points to vinnyd79 since his responses got me thinking about double checking what the Command$ was returning and I noticed the problem of the quotes being passed into the variable holding the path location and filename.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question