![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: A Mile High!!
Posts: 230
|
Does anyone know why a VBA would stop with out an error? It just runs and then stops in the middle of what it is doing? Here is the code:
If Range("c18").Value Then Application.ScreenUpdating = False Workbooks.Open FileName:= _ "\serverfolderMaterialsJimFJim.xls", _ UpdateLinks:=3, WriteResPassword:="jim" 'check to see if read only If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Saved = True ActiveWorkbook.Close Range("e18").Select Application.ScreenUpdating = True ActiveCell.FormulaR1C1 = "Not Updated" GoTo lastlinejim: End If 'update file Range("a1").Select ActiveWorkbook.Save ActiveWindow.Close Range("i18").Select ActiveCell.FormulaR1C1 = "Updated" Application.ScreenUpdating = True lastlinejim: Range("a1").Select End If 'displayed if not selected If Range("c18") <> "True" Then Range("e18").Select ActiveCell.FormulaR1C1 = "Not Selected" |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Perhaps you may need to clarify what it is that you're asking.
Is it raising an error? If it isn't, one way code stops running without an error is that there are no errors in the code. (this is the aim of every programmer Is the code just crapping out and not letting you debug? |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: A Mile High!!
Posts: 230
|
Nope it just stops. It runs along and then just quits in the middle of the process. What is weird is that it doesnt do it on my other machine. But I have this problem on the machines of the people I did this for too. It is just one file in a list that this is a part of. If I have selections made after it, it doesnt go on to those. Any ideas?
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Any idea which line it stops at?
You can step through the code one line at a time. Got to the VBE. Right click on a toolbar at the top, choose Debug. Go to the sub with this code in it and put the cursor somewhere in the code. On the Debug toolbar, hit the "Step Into" button (button beside the hand) to run the code one line at a time. Do this and you'll find out which line of code it craps out on. |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: A Mile High!!
Posts: 230
|
It is stopping just after 'update file.
I tried the stepping through and it went all the way through. Is this maybe just a flukey thing? Now its not doing it all the time. Oh crap. [ This Message was edited by: EdE on 2002-05-07 11:11 ] |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Is the workbook always read only? If it's read only, you're effectively telling the macro to end by sending it to the label "lastlinejim".
Are you open to suggestions for "improving" the code? |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: A Mile High!!
Posts: 230
|
It is never read only because you need to enter passwords to even open. I am having this problem on several versions of this, that is I created a template for ease of use to other programs. But I never had a problem with this until yesterday. Any improvement suggestions would be welcomed for sure!!
Thanks! |
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Why have this line if it's never Read Only?
If ActiveWorkbook.ReadOnly Then I'll have a better look at this tomorrow, but it seems like you only need about 5 lines of code. Code you tell me exactly what this code is supposed to be? |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2002
Location: A Mile High!!
Posts: 230
|
Sorry Mark. I shouldnt have said it is never read only. It is supposed to just open the file to update links and then closes. If it is opened as read only, it skips to the end and goes on to the next one. Any guesses?
[ This Message was edited by: EdE on 2002-05-10 09:32 ] |
|
|
|
|
|
#10 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
I don't understand this bit of code from your original post:
Is this in another subroutine or something? EDIT:: Scratch that, never mind, I just can't read. _________________ [b] Mark O'Brien [ This Message was edited by: Mark O'Brien on 2002-05-10 09:11 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|