Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default MsgBox - How to display In Other Instance of Excel


Hi All,

I am using a separate instance of excel to display an export from an
excel application in a different instance of excel (the original
instance being driven entirely by modal userforms which I don't want
to interrupt).

One export is a data integrity check where it exports, does some
checks, and then displays the lines with potential issues for the user
to investigate back to hard copy documents.

I would like to display a MsgBox in that instance of excel, using code
in my original instance, telling the user which specific test was
found to have potential data issues (makes it easier for the user to
target their investigation / checking).

However, I cannot work out how to make it display a MsgBox
in the other instance of excel.

Any suggestions?

Thanks,

Alan.


PS: I have looked through the excel object model for where a
MsgBox sits, but I cannot seem to see where it fits into the
hierarchy. I was hoping to be able to reference it something
like this:

+-+-+-+-+-+-+-+-+-+-+

This Instance Implicit:

MsgBox "Hello"

+-+-+-+-+-+-+-+-+-+-+

This Instance Explicit:

Thisworkbook.Parent.MsgBox "Hello"

+-+-+-+-+-+-+-+-+-+-+

Other Instance (objExcel being the new instance of excel):

objExcel.MsgBox "Hello"

+-+-+-+-+-+-+-+-+-+-+


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MsgBox - How to display In Other Instance of Excel

have the instance in control run a macro in the other instance that displays
the msgbox

oxlApp.Application.Run "Tempbook.xls!Macro1"

--
Regards,
Tom Ogilvy

"Alan" wrote in message
...

Hi All,

I am using a separate instance of excel to display an export from an
excel application in a different instance of excel (the original
instance being driven entirely by modal userforms which I don't want
to interrupt).

One export is a data integrity check where it exports, does some
checks, and then displays the lines with potential issues for the user
to investigate back to hard copy documents.

I would like to display a MsgBox in that instance of excel, using code
in my original instance, telling the user which specific test was
found to have potential data issues (makes it easier for the user to
target their investigation / checking).

However, I cannot work out how to make it display a MsgBox
in the other instance of excel.

Any suggestions?

Thanks,

Alan.


PS: I have looked through the excel object model for where a
MsgBox sits, but I cannot seem to see where it fits into the
hierarchy. I was hoping to be able to reference it something
like this:

+-+-+-+-+-+-+-+-+-+-+

This Instance Implicit:

MsgBox "Hello"

+-+-+-+-+-+-+-+-+-+-+

This Instance Explicit:

Thisworkbook.Parent.MsgBox "Hello"

+-+-+-+-+-+-+-+-+-+-+

Other Instance (objExcel being the new instance of excel):

objExcel.MsgBox "Hello"

+-+-+-+-+-+-+-+-+-+-+




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default MsgBox - How to display In Other Instance of Excel

"Tom Ogilvy" wrote in message
...

have the instance in control run a macro in the other instance that
displays the msgbox

oxlApp.Application.Run "Tempbook.xls!Macro1"


Hi Tom,

Thanks for your quick reply.

I guess that implicitly means that I have to programmatically create
the macro in the workbook in the new instance, since that workbook was
created from scratch by my code.

I found the following post by the anonymous 's':

http://groups.google.co.nz/groups?hl...nnrp1.deja.com

which I amended slightly to try to do what I need (see below bottom).

The code errors out with an error 438 (object does not support this
property or method) on the line between my commented asterixes (****).

If I remove that line, it bombs out on the next line with the same
error.

I added that first line guessing that I needed to add a module first,
but obviously the issue is not (just) that?

Are you able to point me in the right direction?

Thanks,

Alan.


+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+

' Note: This code simplified to avoid excess post length'
' Only change was to reduce the MsgBox text to "Hello"


Sub Create_Code_In_Workbook(objexcel As Application, _
FieldNumberBlank As Integer, _
FieldNumberNonBlank As Integer, _
TotalRows As Integer)

' ****

objexcel.VBProject.VBcomponets.Add (vbext_ct_StdModule)

' ****

Set MyProject = objexcel.VBProject.VBcomponets("Module1").Codemodu le

yourcode = "Sub Display_MsgBox" & vbCrLf
yourcode = yourcode + "Response = MsgBox(""Hello"")" & vbCrLf
yourcode = yourcode + "end sub"

With MyProject
.insertlines 3, yourcode
End With

End Sub

+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MsgBox - How to display In Other Instance of Excel

you mispelled component same as in the posting you cited.

objExcel should not be application, but a workbook.

this worked for me in a single instance:

Sub Create_Code_In_Workbook(objBk As Workbook, _
FieldNumberBlank As Integer, _
FieldNumberNonBlank As Integer, _
TotalRows As Integer)
Dim modl As Object

' ****

Set modl = objBk.VBProject.VBComponents.Add(vbext_ct_StdModul e)

' ****

Set myproject = modl.CodeModule

yourcode = "Sub Display_MsgBox" & vbCrLf
yourcode = yourcode + "Response = MsgBox(""Hello"")" & vbCrLf
yourcode = yourcode + "end sub"

With myproject
.insertlines 3, yourcode
End With

End Sub

Sub Tester2()
Create_Code_In_Workbook ThisWorkbook, 1, 2, 3
Application.Run ThisWorkbook.Name & "!Display_MsgBox"
End Sub

--
Regards,
Tom Ogilvy


"Alan" wrote in message
...
"Tom Ogilvy" wrote in message
...

have the instance in control run a macro in the other instance that
displays the msgbox

oxlApp.Application.Run "Tempbook.xls!Macro1"


Hi Tom,

Thanks for your quick reply.

I guess that implicitly means that I have to programmatically create
the macro in the workbook in the new instance, since that workbook was
created from scratch by my code.

I found the following post by the anonymous 's':


http://groups.google.co.nz/groups?hl...nnrp1.deja.com

which I amended slightly to try to do what I need (see below bottom).

The code errors out with an error 438 (object does not support this
property or method) on the line between my commented asterixes (****).

If I remove that line, it bombs out on the next line with the same
error.

I added that first line guessing that I needed to add a module first,
but obviously the issue is not (just) that?

Are you able to point me in the right direction?

Thanks,

Alan.


+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+

' Note: This code simplified to avoid excess post length'
' Only change was to reduce the MsgBox text to "Hello"


Sub Create_Code_In_Workbook(objexcel As Application, _
FieldNumberBlank As Integer, _
FieldNumberNonBlank As Integer, _
TotalRows As Integer)

' ****

objexcel.VBProject.VBcomponets.Add (vbext_ct_StdModule)

' ****

Set MyProject = objexcel.VBProject.VBcomponets("Module1").Codemodu le

yourcode = "Sub Display_MsgBox" & vbCrLf
yourcode = yourcode + "Response = MsgBox(""Hello"")" & vbCrLf
yourcode = yourcode + "end sub"

With MyProject
.insertlines 3, yourcode
End With

End Sub

+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default MsgBox - How to display In Other Instance of Excel

"Tom Ogilvy" wrote in message
...

you mispelled component same as in the posting you cited.


Serves me right I suppose!


objExcel should not be application, but a workbook.

this worked for me in a single instance:


{Snipped code}



Hi Tom.

Apologies for being slow, but I still cannot get it to work.

I have simplified everything to the code below, and used a separate
object name at each step in order to confirm exactly where it goes
wrong:

It stops on the lie where I try to add a Standard Module to the
VBComponent (spelt correctly now I think!).

I am using Excel 2000 SP3 running under Win2000 Pro - all fully
patched and updated.

Thanks again,

Alan.


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Sub Test()

Dim objExcel As Application
Dim objExcelWorkbook As Workbook
Dim MyProject As Object
Dim MyComponents As Object
Dim MyStdModule As Object


Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objExcelWorkbook = objExcel.Workbooks.Add


Set MyProject = objExcelWorkbook.VBProject
Set MyComponents = MyProject.VBComponents


' **** Bombs on the following line ****

Set MyStdModule = MyComponents.Add(vbext_ct_StdModule)

' **** Bombs on the line above ****


End Sub









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default MsgBox - How to display In Other Instance of Excel

I see you have declared your variables as Object which would be appropriate
if you are using late binding (no reference to the visual basic
extensibility library). However, if that is the case

vbext_ct_StdModule

is an uninitialized variant variable with value 0. where it should have a
value of 1

? vbext_ct_StdModule
1


Zero would not be a legal argument to the line of code. Hard code a 1
(one).

--
Regards,
Tom Ogilvy

"Alan" wrote in message
...
"Tom Ogilvy" wrote in message
...

you mispelled component same as in the posting you cited.


Serves me right I suppose!


objExcel should not be application, but a workbook.

this worked for me in a single instance:


{Snipped code}



Hi Tom.

Apologies for being slow, but I still cannot get it to work.

I have simplified everything to the code below, and used a separate
object name at each step in order to confirm exactly where it goes
wrong:

It stops on the lie where I try to add a Standard Module to the
VBComponent (spelt correctly now I think!).

I am using Excel 2000 SP3 running under Win2000 Pro - all fully
patched and updated.

Thanks again,

Alan.


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Sub Test()

Dim objExcel As Application
Dim objExcelWorkbook As Workbook
Dim MyProject As Object
Dim MyComponents As Object
Dim MyStdModule As Object


Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objExcelWorkbook = objExcel.Workbooks.Add


Set MyProject = objExcelWorkbook.VBProject
Set MyComponents = MyProject.VBComponents


' **** Bombs on the following line ****

Set MyStdModule = MyComponents.Add(vbext_ct_StdModule)

' **** Bombs on the line above ****


End Sub









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 display remaining txt file which overflowed MsgBox display? EagleOne Excel Discussion (Misc queries) 1 November 2nd 06 01:10 PM
Excel VBA - MsgBox to display variable value? BruceAtkinson[_5_] Excel Programming 2 June 4th 04 08:32 PM
Display MsgBox thru automation Per-Olof Excel Programming 1 January 13th 04 07:39 AM
DISPLAY RANGE AT MSGBOX GUS Excel Programming 2 September 25th 03 08:38 PM
Specify font for MsgBox display? shockley Excel Programming 1 September 11th 03 01:50 PM


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