I have a question, does anyone know why "Div/0" error comes up in VB? My program reads/writes to several files. On my computer and one of my friends computer, it works perfectly; though there are some desktops machines that I receive that error.

When I step through the program to the highlighted problem (Usually on the saveas line) and step through manually, the program runs beautifully but when when i auto run it, I get several different errors.

Could it be the several objects are not working in those computers that are giving error messages?

Ini

That's an excel divide by 0 error.... is your app doing something with excel? If so, maybe
A) Excel is not install on the client machine
B) Wrong version of excel for the method/operation your app does
C) problem with a calculation in the excel document

You could TRY throwing in an on error resume next just before the saveas line, or an on error goto handler , but then you need to make a handler: label to goto. I don't know if that will work or not, because if the error is with the excel object, your app will have little or no say in the objects internal error handling technique.....

Thanks, I will try the on error resume next. The funny thing is this, when I log into the system, my program runs fine; when I sign in as my brother and run the same program, I get the div by 0 error and when I step through it, it works. When I then click on the auto run, I then get the object not set.

the div/0 faults at the line of code below -

Set wb = Workbooks.Open("C:\Files\a.xls", True, False)

I get the "Object not set error at the saveas line below -

wb.SaveAs Filename:="C:\Files\Report for" & " " & Zt & ".xls", FileFormat:=xlWorkbookNormal, addtomru:=True
 
 
 
'where Zt is today's date

I would like to find out, if I put the on Error Resume next right at the point of the file Open (former error), will my program just ignore opening up that file (if it does, the program will be pointless).


prior to these series of errors, I have in code "opened, made changes and saved as" and did not get these error, but for some reason when it goes down to that particular line, I receive the error

Ini

I also noticed that when it reaches this line below


Set wb = Workbooks.Open("C:\Files\a.xls", True, False)


It does open up the file, though wb will always = Nothing (that's not good).


Ini

On my computer and one of my friends computer, it works perfectly; though there are some desktops machines that I receive that error.

when I log into the system, my program runs fine; when I sign in as my brother and run the same program, I get the div by 0 error

This makes me think you might have permission issues with the files maybe.

I get several different errors.

What are these other errors please.

From microsoft explorer, I went to a selected file property -> security -> and gave access to several people (since my program is on a network). When I tried running my program from a different computer I got the same error.

It is kind of weird that the individual who shares my desktop with me is obtaining the error when he tries running my program, but when I log in I am able to run my program just fine.

Do you think if I put in a message box which would capture the error number other than error # 11, would I then be able to tell what the problem seems to be ?

Ini

Yeah, give that a shot.

I browsed the MSDN library, going through their search database on excel and found out using "screen.update" command to hide or unhide windows screen usually bring's up errors.

What I did not to comment out the line of codes I had below

Application.ScreenUpdating = False ' turn off the screen updating

I had it before where it had
Application.ScreenUpdating = False ' turn off the screen updating

without reseting it back to true.

For now everything works. Thank you very much for you help guys.


Ini :cheesy:

Hi there,

From on the system that was giving me problems (running my VBA program), I opened up an excel application and under help clicked on detect and repair. Now my code works very well though I have one problem, my program no longer opens up lotus notes when I use

activeworkbook.SendMail _
    Recipients:=[EMAIL="Ini@hotmai.com"]Ini@hotmai.com[/EMAIL], _
    Subject:="This is just a test"

Before it worked until I repaired and detected. The error message that I get says runtime error '1004' Method ' SendMail' of object '_workbook' failed.

Do I need to Tools -> References (in VB) inorder to add an object? If so what object do I need to add inorder to open up lotus notes not outlook. I clicked on an object that said "lotus notes" and still got an error.


Ini

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.