Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Showing a Msgbox in the active application

Hi,

I'm hoping this is an easy one! I've spent some time searching for a
answer on this forum but to no avail.

I have a macro that is run from MS Project. It opens and activates a
excel workbook and copies some information from it.

However I cant seem to get any msgbox messages to show up in the exce
application. Instead they always appear within MS Project and the onl
way to view it is to manaully switch back to MS Project.

How can I make sure that msgbox's appear in the active application, no
the application where the macro originated?

I hope someone can help.

thanks,

Mat

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Showing a Msgbox in the active application

Qualify the MsgBox command with the Excel object

xlApp.MsgBox etc.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"donovanm " wrote in message
...
Hi,

I'm hoping this is an easy one! I've spent some time searching for an
answer on this forum but to no avail.

I have a macro that is run from MS Project. It opens and activates an
excel workbook and copies some information from it.

However I cant seem to get any msgbox messages to show up in the excel
application. Instead they always appear within MS Project and the only
way to view it is to manaully switch back to MS Project.

How can I make sure that msgbox's appear in the active application, not
the application where the macro originated?

I hope someone can help.

thanks,

Matt


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Showing a Msgbox in the active application

Thanks for the reply. However, I had already tried your suggestio
thinking it would work, but it doesnt seem to!

Here is a snippet from my code

Set xlApp = CreateObject("Excel.Application")

xlApp.workbooks.Open sMilestonePathFileName

xlApp.Visible = True

xlApp.worksheets(sPPRMilestoneSheetName).Select

xlApp.MsgBox "Hello"


Lines 1 to 4 run fine, but the code fails when it reaches line 5. Th
error message I get is as follows:

Run-time error '438':
Object doesnt support this property or method.

Any suggestions will be greatly appreicated!

thanks,

Mat

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Showing a Msgbox in the active application

You could create macros in the workbook to open and run those (hard work?)
or try this

xlApp.ExecuteExcel4Macro "alert(""Hello"")"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"donovanm " wrote in message
...
Thanks for the reply. However, I had already tried your suggestion
thinking it would work, but it doesnt seem to!

Here is a snippet from my code

Set xlApp = CreateObject("Excel.Application")

xlApp.workbooks.Open sMilestonePathFileName

xlApp.Visible = True

xlApp.worksheets(sPPRMilestoneSheetName).Select

xlApp.MsgBox "Hello"


Lines 1 to 4 run fine, but the code fails when it reaches line 5. The
error message I get is as follows:

Run-time error '438':
Object doesnt support this property or method.

Any suggestions will be greatly appreicated!

thanks,

Matt


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Showing a Msgbox in the active application

Ok, thanks Bob.

xlApp.ExecuteExcel4Macro "alert(""Hello"")"

Your line does work. However I assume I wont be able to create
Yes/No/Cancel msgbox using this type of approach?

Could you tell me (or point me in the direction of some info) on how
can run an Excel macro contained in a workbook from MS project/MS Wor
etc? You say it is hard work, but I think in my case it would save m
some problems.

thanks,

Mat

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Showing a Msgbox in the active application

Matt,

The actual call is quite simple

xlApp.Run Activeworkbook.Name & "!MacroName"

The hard work comes in setting up a macro in that workbook that displays a
message box, as it will need to be in all target workbooks, and reduces your
code flexibility.

Also, as your seemed concerned to have MsgBox with Yes No buttons, you will
need to create a function in the workbook(s), and return the resul, and test
that in your original code, like

Function myFunc()

myFunc = MsgBox("Hello", vbYesNo)

End Function

in the workbook(s), and call with


ans = xlapp.Run(ActiveWorkbook.Name & "!myFunc")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"donovanm " wrote in message
...
Ok, thanks Bob.

xlApp.ExecuteExcel4Macro "alert(""Hello"")"

Your line does work. However I assume I wont be able to create a
Yes/No/Cancel msgbox using this type of approach?

Could you tell me (or point me in the direction of some info) on how I
can run an Excel macro contained in a workbook from MS project/MS Word
etc? You say it is hard work, but I think in my case it would save me
some problems.

thanks,

Matt


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Showing a Msgbox in the active application

"Bob Phillips" wrote ...

The hard work comes in setting up a macro in that workbook that displays a
message box, as it will need to be in all target workbooks, and reduces your
code flexibility.


If you are not afraid of hard work you could investigate the
possibility of using the Win32 API MessageBox. A brief look at the
code he

http://vbnet.mvps.org/index.html?cod...xhooktimer.htm

suggests you can specify the owner window for a messagebox.

Jamie.

--
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Showing a Msgbox in the active application

Ok, this looks like I'm getting somewhere!

Thanks for your help!

Mat

--
Message posted from http://www.ExcelForum.com

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 Determine if Application Window Still Active Edwin Kelly Excel Discussion (Misc queries) 3 June 26th 07 05:42 PM
VBA: Make Excel the active application Gaetan Excel Discussion (Misc queries) 0 March 19th 07 05:57 PM
MsgBox with condition and showing details viddom Excel Worksheet Functions 2 August 17th 05 12:38 PM
How to read active Excel celll value by external vb application? Jack Excel Programming 2 February 11th 04 09:06 PM
Showing Search results in msgbox? Ed[_9_] Excel Programming 1 August 28th 03 05:13 PM


All times are GMT +1. The time now is 08:56 PM.

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

About Us

"It's about Microsoft Excel"