Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Need to make sure workbook is open before proceeding

Can you help - Users of my form need to make sure Doc2 is open before running
the macro. If Doc2 is not open I need the macro to stop and a message box to
pop up stating Doc2 is not open.


Application.WindowState = xlMinimized


Range("H2").Select
Selection.Copy


Range("E1").Select
ActiveSheet.Paste

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Need to make sure workbook is open before proceeding

Dim Doc2Wkbk as workbook

set doc2wkbk = nothing
on error resume next
set doc2wkbk = workbooks("doc2.xls") 'no drive and no path
on error goto 0

if doc2wkbk is nothing then
msgbox "It's not open"
exit sub
end if

=========
Maybe you could have your code just open it (if you know where it is):

if doc2wkbk is nothing then
on error resume next
'include drive and path on the next line
set doc2wkbk = workbooks.open(filename:="c:\path\doc2.xls")
on error goto 0

if doc2wkbk is nothing then
msgbox "it's not open and I don't know where it is!
exit sub '????
else
msgbox "it was opened, but now it is!"
end if
end if



Munchkin wrote:

Can you help - Users of my form need to make sure Doc2 is open before running
the macro. If Doc2 is not open I need the macro to stop and a message box to
pop up stating Doc2 is not open.

Application.WindowState = xlMinimized


Range("H2").Select
Selection.Copy


Range("E1").Select
ActiveSheet.Paste


--

Dave Peterson
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
auto open workbook to make read-only Tim C[_4_] Excel Programming 3 May 10th 09 10:54 AM
Make Workbook Password protected tp open Stockwell43 Excel Discussion (Misc queries) 4 July 2nd 08 12:44 AM
Verify before proceeding snowing[_5_] Excel Programming 7 June 6th 06 01:49 PM
How do i make excel open a new workbook and run a query from sql Dhruv Sampat Excel Programming 3 November 15th 05 01:39 PM
How do I make an open workbook the active workbook Don Guillett[_4_] Excel Programming 0 December 30th 03 04:28 PM


All times are GMT +1. The time now is 03:06 PM.

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

About Us

"It's about Microsoft Excel"