Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Cannot get message box to show

I have a macro in File01.xls that opens File02.xls and then does an
Appliction.Run on the Auto_Open macro in File02.xls:

Private Sub MacroOpenFile02()

Workbooks.Open Filename:= "C:\File02.xls", Password:="aoaoao"
Application.Run "'C:\File02.xls'!Auto_Open"
Windows("File01.xls").Close (0)

End Sub

Now when the macro Application.Run "'C:\File02.xls'!Auto_Open" runs there is
a test in the code that depeding on the result, I may close the file with
Windows("File02.xls").Close(0) ; Now it returns back to continue in macro
in File01.xls I think but I want to put up a message saying File02.xls has an
error and cannot be open. I have made it work in File02.xls by putting the
MsgBox code line right before the Close(0) code line. But that means
File02.xls is open behind the MsgBox. When the user clicks ok on the MsgBox
it closes the file, but what I want is if there was an error for File02.xls,
that it closes so the user will not see File02.xls ... and then return to
File01.xls macro and show a MsgBox from File01.xls macro.

How do I accomplish this?

Thank you,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 434
Default Cannot get message box to show

hi, Steven !

can we assume that *only IF* an error occurs during process, File02.xls is (auto)closed
(otherwise it remains opened) -???-

if so, you can *test* IF file02.xls is still opened with something like...

Workbooks.Open Filename:= "c:\file02.xls", Password:="aoaoao"
Application.Run "'c:\file02.xls'!auto_open"
On Error Resume Next
Debug.Print Workbooks("file02.xls").Type
If Err Then MsgBox "An error has arised and File02.xls is NOT open any more !!!"

BTW using Windows("filename.XLS") could fail on systems where settings for registered FileType
are settled for NOT showing it's filename EXTensions -?-

hth,
hector.

__ OP __
I have a macro in File01.xls that opens File02.xls and then does an
Appliction.Run on the Auto_Open macro in File02.xls:
Private Sub MacroOpenFile02()
Workbooks.Open Filename:= "C:\File02.xls", Password:="aoaoao"
Application.Run "'C:\File02.xls'!Auto_Open"
Windows("File01.xls").Close (0)
End Sub

... when... "'C:\File02.xls'!Auto_Open" runs there is a test in the code that depeding on the result
I may close the file with Windows("File02.xls").Close(0). Now it returns back to continue in macro in File01.xls
I think but I want to put up a message saying File02.xls has an error and cannot be open.
I have made it work in File02.xls by putting the MsgBox code line right before the Close(0) code line.
But that means File02.xls is open behind the MsgBox.
When the user clicks ok on the MsgBox it closes the file
but what I want is if there was an error for File02.xls, that it closes so the user will not see File02.xls
... and then return to File01.xls macro and show a MsgBox from File01.xls macro...



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
Show a message but not in MsgBox RobN[_2_] Excel Discussion (Misc queries) 2 May 30th 08 11:58 PM
message box does not show Marilyn Excel Discussion (Misc queries) 2 May 15th 08 11:44 PM
If A0, I need a message pop-up box to show text in B1 [email protected] Excel Programming 4 December 31st 06 11:04 PM
Message box to show cell value scottwilsonx[_29_] Excel Programming 4 September 7th 04 10:59 AM
show message Mark Kubicki Excel Programming 6 December 19th 03 01:54 PM


All times are GMT +1. The time now is 06:57 AM.

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"