![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
How can I create an inputbox that where the text can contain 2 lines.
First line:=Application.Inputbox(prompt:="Give your number." Second line : "Number as 00.000" Who can help? Many thanks |
|
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Try the following:
Code:
Sub example()
n = Application.InputBox(prompt:="Give your number." _
& Chr(13) & Chr(13) & "Number as 00.000", Type:=1)
End Sub
_________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-26 12:04 ] |
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Quote:
|
|
|
|
|
|
|
#4 | |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Quote:
There should be an OK and Cancel button and that's life with this dialog, no need for additional code. |
|
|
|
|
|
|
#5 | ||
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Quote:
When I press the button OK then the macro runs to the end.But when I press CANCEL then I receive an errormessage. The CANCEL-button must return to the inputplace. How do I insert such a code? Many thanks |
||
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
I don't get the error when I cancel, maybe we're on different versions, but try this
Code:
Sub example2()
On Error Resume Next
n = Application.InputBox(prompt:="Give your number." _
& Chr(13) & Chr(13) & "Number as 00.000", Type:=1)
End Sub
|
|
|
|
|
|
#7 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Quote:
Here is the part of my macro: Sub Mail() Dim olApp As Object, olMail As Object Dim rngeAddresses As Range, rngeCell As Range Set olApp = reateObject"Outlook.Application") Set rngeAddresses = Application.InputBox(prompt:="Give number." _ & Chr(13) & Chr(13) & "(Number as 00.000)") For Each rngeCell In rngeAddresses.Cells Set olMail = olApp.CreateItem(olMailItem) olMail.To = rngeCell.Value |
|
|
|
|
|
|
#8 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Error trapper time, in fact now that I look at, you need to exit the procedure on Cancel like this:
Code:
Sub Mail()
Dim olApp As Object, olMail As Object
Dim rngeAddresses As Range, rngeCell As Range
Set olApp = CreateObject("Outlook.Application")
On Error GoTo errorhandler 'in the event you cancel
Set rngeAddresses = Application.InputBox(prompt:="Give number." _
& Chr(13) & Chr(13) & "(Number as 00.000)")
For Each rngeCell In rngeAddresses.Cells
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = rngeCell.Value
'Insert the rest of your code right here
errorhandler:
End Sub
Cheers, NateO [ This Message was edited by: nateo on 2002-04-26 13:32 ] |
|
|
|
|
|
#9 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
|
This is a sample utility to ask the user if they want to print. It contains your cancel code.
Sub myPrint1() Dim Msg, Style, Title, Help, Ctxt, Response, MyString Msg = "Print Data Now?" ' Define message. Style = vbOKCancel ' Define buttons. Title = "Ready to Print?" ' Define title. 'Help = "DEMO.HLP" ' Define Help file. 'Ctxt = 1000 ' Define topic ' context. ' Display message. Response = MsgBox(Msg, Style, Title) If Response = vbOK Then ' User chose Yes. Columns("AA:AI").Select ActiveSheet.PageSetup.PrintArea = "$AA:$AI" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True ActiveWindow.ScrollColumn = 1 Else ' User chose No. GoTo Can End If End Can: End Sub You can add your own code inplace of this code: Columns("AA:AI").Select ActiveSheet.PageSetup.PrintArea = "$AA:$AI" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True ActiveWindow.ScrollColumn = 1 You control the MsgBox with the variables loaded up top. The trick is the "End" statement and the dummy line call "Can:" Hope this helps. JSW P.S. You can also pull the xlCancel property if you wish. JSW |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|