Solved

RUN TIME ERRO 52

Posted on 2010-09-17
6
520 Views
Last Modified: 2012-05-10


Run-time error '52'

Bad file name or number

On debug highlighted on following line
Open csvflname for output as #iFileNo


Dim iFileNo as integer
dim csvflname as integer

csvflname = text1(8) & ".csv"

Open csvflname for output as #iFileNo

Open in new window

0
Comment
Question by:crystalsoft
[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
6 Comments
 
LVL 13

Expert Comment

by:AielloJ
ID: 33700510
crystalsoft:

Where is the varible 'text1' initialized?  Try printing csvfilename and text1 for debug purposes.

AielloJ
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33700554
Make sure that csvflname = text1(8) & ".csv" contains a valid name and not something like this ".csv"
Check the value of text1(8)
0
 
LVL 1

Author Comment

by:crystalsoft
ID: 33700566

Thanks for quick reply sir

text1(8) is a text box

csvflname = text1(8) & ".csv"

on debug i am getting file name like 43.csv

43 is value from text1(8)
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 125 total points
ID: 33700598
does 43.csv exist?

try text1(8).text

see this link:
http://www.experts-exchange.com/Programming/Misc/Q_26474347.html
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 125 total points
ID: 33700601
What is the value of #iFileNo ?

Perhaps you need to add something like this:

#iFileNo = freefile()
Open csvflname for output as #iFileNo
0
 
LVL 14

Expert Comment

by:VBClassicGuy
ID: 33702367
Just an observation no one picked up on, and something to watch out for in the future. In your original posted code, you declared csvflname as an integer, then assigned a text value to it. That's a no-no.
Fixing that and setting iFileNo with FreeFile would have made the code work (assuming text1(8) is a valid control on your form).
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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…

622 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