Macro not finishing due to loading workbook

D

David P.

I have a macro that opens another workbook but it appears that the macro
fails to finish because it's almost like it's not waiting for it to load.
Essentially this is what I'm doing:

Workbook A is open
Macro to open Workbook B (this takes a second to load therefore cancelling
the rest of the macro)
Copy selected text from B
Close Workbook B
Paste info on Workbook A

Your help appreciated.
 
J

Jim Rech

Macro to open Workbook B

How do you execute this macro? Keyboard shortcut?

--
Jim
|I have a macro that opens another workbook but it appears that the macro
| fails to finish because it's almost like it's not waiting for it to load.
| Essentially this is what I'm doing:
|
| Workbook A is open
| Macro to open Workbook B (this takes a second to load therefore cancelling
| the rest of the macro)
| Copy selected text from B
| Close Workbook B
| Paste info on Workbook A
|
| Your help appreciated.
| --
| David P.
 
D

David P.

Now I'm really going to confuse you. I'm assuming the macro stops running at
Workbooks.Open Filename:="C:\Windows Template.xls" .

Sheets("P").Select
Range("I13").Select
Workbooks.Open Filename:="C:\Windows Template.xls"
Sheets("2").Select
Selection.Copy
ActiveWindow.WindowState = xlMinimized
ActiveWindow.WindowState = xlMaximized
ActiveSheet.Paste
ActiveWindow.WindowState = xlMinimized
Windows("Windows Template.xls").Activate
ActiveWindow.Close
 
D

David P.

Yes, by keyboard shortcut.
--
David P.


Jim Rech said:
How do you execute this macro? Keyboard shortcut?

--
Jim
|I have a macro that opens another workbook but it appears that the macro
| fails to finish because it's almost like it's not waiting for it to load.
| Essentially this is what I'm doing:
|
| Workbook A is open
| Macro to open Workbook B (this takes a second to load therefore cancelling
| the rest of the macro)
| Copy selected text from B
| Close Workbook B
| Paste info on Workbook A
|
| Your help appreciated.
| --
| David P.
 
D

Dave Peterson

Remove the shift key from the shortcut combination.

Holding down the shiftkey while you're opening a file tells excel not to run the
workbook_open event or the auto_open procedure. And it confuses excel so that
it never goes back to finish your code.
 
J

Jim Rech

What Dave said holds even if the workbook you're opening doesn't have any
macros. It kills the calling macro too.

--
Jim
| Yes, by keyboard shortcut.
| --
| David P.
|
|
| "Jim Rech" wrote:
|
| > >>Macro to open Workbook B
| >
| > How do you execute this macro? Keyboard shortcut?
| >
| > --
| > Jim
| > | > |I have a macro that opens another workbook but it appears that the
macro
| > | fails to finish because it's almost like it's not waiting for it to
load.
| > | Essentially this is what I'm doing:
| > |
| > | Workbook A is open
| > | Macro to open Workbook B (this takes a second to load therefore
cancelling
| > | the rest of the macro)
| > | Copy selected text from B
| > | Close Workbook B
| > | Paste info on Workbook A
| > |
| > | Your help appreciated.
| > | --
| > | David P.
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top