View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Test that a workbook is open

Hi
try something like the following (I assume you mean a workbook and not
a worksheet)

sub foo()
dim wbk as workbook
on error resume next
set wbk = workbooks("your_workbookname.xls")
if err.number<0 then
msgbox "Workbook is not open"
exit sub
end if
'now your other code
end sub

--
Regards
Frank Kabel
Frankfurt, Germany

"Gef" schrieb im Newsbeitrag
...
Hi,

I have a macro that I want to start with a paste command
(data copied from another system) but only if the
following conditions are met:

1 There is a worksheet open
2 It is empty
3 The first two columns have been formatted as text.

I can do (2), and can set the columns to text before the
paste - so can do (3).

Can anyone help me with a test to ensure there is a
worksheet open (a user might press the icon I set up when
there is no workbook open)

Thanks,


Gef