Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Test that a workbook is open

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Test that a workbook is open

Heres one approach:

Sub test()
If Not ActiveWindow Is Nothing Then
If Not ActiveWindow.ActiveSheet Is Nothing Then
MsgBox "OK!"
End If
End If
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Gef" wrote in message
...
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



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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
Test to see if a workbook is open Brettjg Excel Discussion (Misc queries) 1 March 5th 07 09:26 AM
test for workbook open Rich C Excel Programming 1 March 1st 04 02:52 PM
Test to see if a spreadsheet window is open lopsided[_6_] Excel Programming 2 December 17th 03 10:42 AM


All times are GMT +1. The time now is 11:45 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"