Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default allow user to change workbook while in Msgbox or InputBox

Hi guys,
This is probably a question of vocab - I didn't know the right terms to
search for, so my apologies if this has been answered.

I need to prompt a user to select a chart and then set that chart to a
variable in my code. The trick is that the chart will be in a
different workbook; is there a way to pop up a message, allow the user
to activate a different workbook and then return to the message a click
OK? I don't know if msgbox or inputbox would allow this.

The general schematic is as follows:

Dim ch as Chart
dim ans as Integer
On Error Resume Next
ans = MsgBox("Please Select a Chart to Modify", Buttons:=vbOKCancel)
'this is where I need to allow the user to go activate a chart
'in another workbook, and then come back and click OK.
If ans = vbOK Then
Set ch = ActiveChart
If ch Is Nothing Then
MsgBox "no chart selected"
Else
'chart okay; more code here
End If
Else
'user canceled out
End If

Thanks in advance for your help,
Andrew

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default allow user to change workbook while in Msgbox or InputBox

" wrote:
I need to prompt a user to select a chart and then set that chart to a
variable in my code. The trick is that the chart will be in a
different workbook; is there a way to pop up a message, allow the user
to activate a different workbook and then return to the message a click
OK? I don't know if msgbox or inputbox would allow this.


MsgBoxes are modal, which means that you can't do other things while one is
on screen. The only options for modality for a MsgBox are Application modal,
which means it stops only Excel, and System modal, which means that the
MsgBox stays live and halts all actions even if you switch applications.
Neither of these helps you.

A UserForm will do what you want. UserForms can be displayed non-modally.
In the VBE, Insert a UserForm in the VBA project for your starting workbook.
Then double click on the form in the Project Manager to display the form
designer. Hit F4 to see the form's properties. Look for "ShowModal" in the
list of properties and set it to False. (Double click on True to change it
to False.)

Drag a button from the Toolbox palette and place it on the form. Double
click the button to see the code for its click event. Enter something like

Debug.Print ActiveWorkbook.Name & " " & ActiveChart.Name
Unload Me

into the event handler.

Go back to the form designer and hit F5 to run the form. The UserForm will
stay on top of the other windows, but you should be able to move it around to
get at and click on charts and whatnot on all the open workbooks in Excel.
You should even be able to make selections from the menu and open new
workbooks.

When you click on the button, the code will write the name of the new
ActiveWorkbook and the ActiveChart in the Immediate Window (assuming you've
actually selected a chart.) Otherwise, the code outline you posted would
work.

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
Help with InputBox and MsgBox Preschool Mike Excel Discussion (Misc queries) 9 April 14th 10 06:23 PM
Help with InputBox and MsgBox Ann New Users to Excel 2 April 11th 07 03:46 PM
msgbox / inputbox etc samenvoegen van sheets Excel Discussion (Misc queries) 2 March 16th 06 08:56 AM
Wait for user to change data after msgbox ???? CanadianTrev Excel Discussion (Misc queries) 1 June 18th 05 08:27 PM
Inputbox() Sum() MsgBox() Nigel Excel Programming 1 August 25th 04 06:20 PM


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