Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Stops executing or keep looping

I generally use the simple approach. See if this works.

Sub Main()
Workbooks.Open Filename:="myfile.xls"
Call Var1
Call Var2
Call Var3
End Sub


"Kenji" wrote in message
...
Some how, either stops in middle of codes or keep looping.
I don't know how to overcome this.
All these are in Module1.

The below is not an actual code, but structure is like so.

Here are my problems with VBA:

1. If "myfile.xls" contains some kind of macros, it stops program after
the file is opened. If I step through, it will go back to "Sub Main()"
because it never goes to the next instruction (Call Procedure(Var1)).
Stepping through will cause looping because it never goes to End Sub.

2. Similar to #1, but after executing "Call Procedure(Var1)", the program
will not go to the next instruction.. If I step through, at the end of

Call
Procedure(Var1), it goes back to Sub Main() again.

Both situations do not cause any errors.

If anyone can help me some possibilties or give me some tips on how to
prevent this, I would really appreciate it.

Thanks.



Sub Main()
Dim Var1 As Integer, Var2 As Integer, Var3 as Integer
Workbooks.Open Filename:="myfile.xls"
Call Procedure(Var1)
Call Procedure(Var2)
Call Procedure(Var3)
End Sub




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Stops executing or keep looping

Application.EnableEvents = False
workbooks.Open "c:\mydocs\myfile.xls"
Application.EnableEvents = True

--
Regards,
Tom Ogilvy

Kenji wrote in message
...
Dear Don,

Foremost, thank you for responding to my question. I think I was not

clear
about my question, however.

Let's assume that myfile.xls contains macro and all sort of junks. It
certainly opens myfile.xls, but it stops there. It won't go to the next
instruction. I'm guessing that it has an open event and exits the
subroutine(?).

What I would like to do is somehow open myfile.xls by disabling macro

first.

Do you have any suggestion?

Thanks again.

"Don Guillett" wrote in message
...
I generally use the simple approach. See if this works.

Sub Main()
Workbooks.Open Filename:="myfile.xls"
Call Var1
Call Var2
Call Var3
End Sub


"Kenji" wrote in message
...
Some how, either stops in middle of codes or keep looping.
I don't know how to overcome this.
All these are in Module1.

The below is not an actual code, but structure is like so.

Here are my problems with VBA:

1. If "myfile.xls" contains some kind of macros, it stops program

after
the file is opened. If I step through, it will go back to "Sub

Main()"
because it never goes to the next instruction (Call Procedure(Var1)).
Stepping through will cause looping because it never goes to End Sub.

2. Similar to #1, but after executing "Call Procedure(Var1)", the

program
will not go to the next instruction.. If I step through, at the end

of
Call
Procedure(Var1), it goes back to Sub Main() again.

Both situations do not cause any errors.

If anyone can help me some possibilties or give me some tips on how to
prevent this, I would really appreciate it.

Thanks.



Sub Main()
Dim Var1 As Integer, Var2 As Integer, Var3 as Integer
Workbooks.Open Filename:="myfile.xls"
Call Procedure(Var1)
Call Procedure(Var2)
Call Procedure(Var3)
End Sub








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stops executing or keep looping

It worked. Thanks.

"Tom Ogilvy" wrote in message
...
Application.EnableEvents = False
workbooks.Open "c:\mydocs\myfile.xls"
Application.EnableEvents = True

--
Regards,
Tom Ogilvy

Kenji wrote in message
...
Dear Don,

Foremost, thank you for responding to my question. I think I was not

clear
about my question, however.

Let's assume that myfile.xls contains macro and all sort of junks. It
certainly opens myfile.xls, but it stops there. It won't go to the

next
instruction. I'm guessing that it has an open event and exits the
subroutine(?).

What I would like to do is somehow open myfile.xls by disabling macro

first.

Do you have any suggestion?

Thanks again.

"Don Guillett" wrote in message
...
I generally use the simple approach. See if this works.

Sub Main()
Workbooks.Open Filename:="myfile.xls"
Call Var1
Call Var2
Call Var3
End Sub


"Kenji" wrote in message
...
Some how, either stops in middle of codes or keep looping.
I don't know how to overcome this.
All these are in Module1.

The below is not an actual code, but structure is like so.

Here are my problems with VBA:

1. If "myfile.xls" contains some kind of macros, it stops program

after
the file is opened. If I step through, it will go back to "Sub

Main()"
because it never goes to the next instruction (Call

Procedure(Var1)).
Stepping through will cause looping because it never goes to End

Sub.

2. Similar to #1, but after executing "Call Procedure(Var1)", the

program
will not go to the next instruction.. If I step through, at the end

of
Call
Procedure(Var1), it goes back to Sub Main() again.

Both situations do not cause any errors.

If anyone can help me some possibilties or give me some tips on how

to
prevent this, I would really appreciate it.

Thanks.



Sub Main()
Dim Var1 As Integer, Var2 As Integer, Var3 as Integer
Workbooks.Open Filename:="myfile.xls"
Call Procedure(Var1)
Call Procedure(Var2)
Call Procedure(Var3)
End Sub










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why are my functions not executing? Charlie Excel Worksheet Functions 1 March 3rd 09 11:21 PM
EXECUTING A FORMULA Theresa New Users to Excel 4 January 18th 07 06:09 PM
executing a macro within another brian Excel Discussion (Misc queries) 3 July 5th 06 01:22 AM
Executing Macros bmorganh Excel Discussion (Misc queries) 1 January 27th 06 12:03 AM
Forumlas Not Executing Trey Excel Discussion (Misc queries) 2 January 25th 06 04:02 PM


All times are GMT +1. The time now is 05:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"