Re: VBA code halts after opening a file
From: Harald Staff (innocent_at_enron.invalid)
Date: 02/01/04
- Next message: Harald Staff: "Re: Text box format VBA"
- Previous message: Ken Wright: "Re: Thanks"
- In reply to: Bill in Inverness: "VBA code halts after opening a file"
- Next in thread: Bill in Inverness: "Re: VBA code halts after opening a file"
- Reply: Bill in Inverness: "Re: VBA code halts after opening a file"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 1 Feb 2004 11:43:19 +0100
Hi Bill
I can only think of two things -assuming that the file actually exists and that you'll
write code to ensure it does in the finished product.
First, you don't specify which *** in the file to go to. And second, opening files may
take a while, insert a DoEvents to give her a little space. Let me also suggest you insert
a On Error GoTo 0
sldo, it clears error handling and so the debugger should provide the corrrect error
message on errors:
Sub test()
On Error GoTo 0
Workbooks.Open Filename:="C:\Tests\OpenTest.xls"
DoEvents
Workbooks("OpenTest.xls").Sheets(1).Activate
DoEvents
Range("B2").End(xlDown).Offset(1, 0).Select
End Sub
--
HTH. Best wishes Harald
Followup to newsgroup only please.
"Bill in Inverness" <anonymous@discussions.microsoft.com> wrote in message
news:2F28C26E-F4D6-4AC6-B059-0D5C4D6AD125@microsoft.com...
> Hi all,
>
> I have a number of files to process and I don't want to add the same duplicative VBA
code to each file. Putting the code into single workbook with a loop to open and process
the files sequentially seemed logical.
>
> However, my code halts after opening the first file. Any idea what might be wrong?
>
> I reduced the code to bare bones (without the loop) and it still quits after opening the
first file. The start of the processing code is simple:
>
> Workbooks.Open Filename:="C:\Tests\OpenTest.xls"
> Range("B2").End(xlDown).Offset(1,0).Select
>
> The computer a new Compaq running Excel XP SP2 with all available Office updates applied
and running under Windows XP Home Edition SP1 with all Critical updates and all but a few
of the Recommended updates installed.
>
> Thanking you in advance, I look forward to enlightenment
>
> Bill
>
- Next message: Harald Staff: "Re: Text box format VBA"
- Previous message: Ken Wright: "Re: Thanks"
- In reply to: Bill in Inverness: "VBA code halts after opening a file"
- Next in thread: Bill in Inverness: "Re: VBA code halts after opening a file"
- Reply: Bill in Inverness: "Re: VBA code halts after opening a file"
- Messages sorted by: [ date ] [ thread ]