How to popup msg box ?

  • Thread starter Thread starter vumian
  • Start date Start date
V

vumian

I have 2 files: file1 and file2

i wanna copy the contain of sheet21 of file2 into sheet11 of file 1
But , if file2 is not active. How to popup msg box for this case ?

thank you for help .
 
Hi vumian

Not needed that the file or sheet is active when you copy

You can test if a file is open with this function

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function


Use like this

If bIsBookOpen("test.xls") Then
 
If Workbooks("abc.xls").Activate = True Then
Call function
Else
MsgBox "Error"
End If

What's wrong with this code

thank your for help
 
Ron said:
Hi vumian

Not needed that the file or sheet is active when you copy

You can test if a file is open with this function

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function


Use like this

If bIsBookOpen("test.xls") Then

--
Regards Ron de Bruin
http://www.rondebruin.nl


Oh, it work great . thank you very much
a good man.
 

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

Back
Top