Does it help if you use this:
I've written a simple routine to open a template sheet and move it into a workbook. Manual method would be to do File, Open.. and the Edit, Move or Copy, select target workbook and OK.
The code works if I step though it in the VB Editor using F8, but as soon as I try running it using F5 or a shortcut key it opens the file OK but refuses to move it to the original workbook. Any ideas, guys?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
jppinto: The workbook I'm uploading to is one someone else creates. Placing a button on this sheet is extra confusion for users. My VB macro runs from a separate utilities workbook (or add-in), so I dont' this is practical. I just want to tell them to press Control-shift-U and it will upload this template sheet.
rorya: It sounded promising, and I agree it's better practice to declare stuff. But sadly it still worked the same way; stepping through with F8 worked, pressing F5 didn't. I assume yours has worked successfully? I should point out that my client's site is still running Excel 2003 with VBA 6.3. Maybe that's the problem.
PS: I also tried Copy instead of Move, but that just had the same effect.
The code is located in a workbook called Macro.xls which is in a window hidden from Excel users.
The template file has no code of any kind. It's basically a simple form for users to fill in.
I've now repeated it in a clean environment; new workbook with just your version of the code in it, with a new virgin test worksheet as target. It still works the same way (F8 works, F5 or shortcut doesn't). The only other thing is an add-in called 3424.xls (WZTMPL.XLA) which is a given of the Excel set-up at this site. I don't know what that is.
With F5 I get the template workbook opened, but the move just doesn't happen. So after running the macro you can see the template still open, but not moved into the target workbook. I've tried adding in a dummy sheet on the assumption it doesn't like leaving nothing behind (clears the object or whatever) but that didn't work either.
It gets weirder. If I put a stop command into rorya's code, after opening the workbook and running with a shortcut or F5, I don't ever hit it. In other words, processing stops after opening the file without an error message.
It looks now like it's nothing to do with move or copy at all - it's all to do with workbooks.open failing without an error trap.
Damned if I know! :)
I was doing some research and came across a similar problem posted elsewhere and the final post mentioned that particular oddity, so I thought I'd check. Might also help narrow it down for further research. If nothing else, it gives me more details if I need to file this as a bug (I wouldn't hold your breath for a fix though!).
Rory
I think it's related to this article on Jan Karel Pieterse's site: http://www.jkp-ads.com/art
Seems
Regards,
Rory
That's really helpful, and as far as I'm concerned it's a solution - my client presses Control-u instead of Control-U, hey presto. However, pedants would say the problem I originally raised hasn't actually been resolved - after all, it dropped out after Workbook.Open with F5, not shift F5. So that part of the question is still open.
All the same, I'm accepting the solution for all practical purposes. Thanks for your help!
Regards,
David
Business Accounts
Answer for Membership
by: jppintoPosted on 2009-11-05 at 02:24:16ID: 25748085
That's because you don't have an ActiveSheet when you run it using the F5 key??
Place a button on you sheet and assign the macro. Then click on the button and it will do what you want it to do...
jppinto