Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
I have a message box that I would like to change the title of. Right now it
say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
This line:
MsgBox Msg To: MsgBox Msg, , "Title" Substituye your title for the word "Title". Note the commas. "Brian" wrote in message ... I have a message box that I would like to change the title of. Right now it say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
Just for clarification:
The message box has three elements: 1. The message must be a string or a string variable. Strings are enclosed in quoteation marks, but the string variables are not. 2. Buttons and icons. These are optional items but the default is vbOK which puts a button with the caption "OK" on the message box display. 3. The title must be a string or string variable. When using the message box as an information medium only, you do not use the parenthesies or equal sign. However when using the message box as a function, you must assign a variable and use the equal sign and then the parentheses to enclose the three elements. I hope this helps rather than confuses. "Brian" wrote in message ... I have a message box that I would like to change the title of. Right now it say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
After I changed it, it still say's Microsoft Excel at the top on the message
box. I also tried to change the = to a -, but it gives me a Compile error: Expected Sub, Function, or Property Meassage In the book I am reading it shows the - sign, not the = sign. Which one should I be using? 'Greeting Message Bozeman Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg, , "Title" Title = "C.E.S." End If Thanks & Merry Christmas "JLGWhiz" wrote: Just for clarification: The message box has three elements: 1. The message must be a string or a string variable. Strings are enclosed in quoteation marks, but the string variables are not. 2. Buttons and icons. These are optional items but the default is vbOK which puts a button with the caption "OK" on the message box display. 3. The title must be a string or string variable. When using the message box as an information medium only, you do not use the parenthesies or equal sign. However when using the message box as a function, you must assign a variable and use the equal sign and then the parentheses to enclose the three elements. I hope this helps rather than confuses. "Brian" wrote in message ... I have a message box that I would like to change the title of. Right now it say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
I got it fixed,
Thanks for all your help & Have a Merry Christmas!! "JLGWhiz" wrote: Just for clarification: The message box has three elements: 1. The message must be a string or a string variable. Strings are enclosed in quoteation marks, but the string variables are not. 2. Buttons and icons. These are optional items but the default is vbOK which puts a button with the caption "OK" on the message box display. 3. The title must be a string or string variable. When using the message box as an information medium only, you do not use the parenthesies or equal sign. However when using the message box as a function, you must assign a variable and use the equal sign and then the parentheses to enclose the three elements. I hope this helps rather than confuses. "Brian" wrote in message ... I have a message box that I would like to change the title of. Right now it say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
If I was doing it, I would use the ComboBox click event. I would put this
code in the UserForm code module. In design mode, right click on the form and select View Code. Paste this in the code window. Private Sub Engineer_2_Click() If Me.Engineer_2.ListIndex = - 1 Then Exit Sub Else If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & Me.Engineer_2.Value Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." Titl = "C.E.S." MsgBox Msg, , Titl End If End Sub Now the code will run as soon as the user selects a name from the ComboBox. If the ComboBox has no selection, then the message box does not display. Notice also that the "e" was remove from the word "Title". That is because, Title is a reserved word that is used in the parameters portion of the message box and some other functions and methods such as InputBox. It is a good practice to avoid using reserved words for variables that might have different definitions and characteristics than those assigned in VBA source code. Have a good Christmas and New Year. "Brian" wrote in message ... I got it fixed, Thanks for all your help & Have a Merry Christmas!! "JLGWhiz" wrote: Just for clarification: The message box has three elements: 1. The message must be a string or a string variable. Strings are enclosed in quoteation marks, but the string variables are not. 2. Buttons and icons. These are optional items but the default is vbOK which puts a button with the caption "OK" on the message box display. 3. The title must be a string or string variable. When using the message box as an information medium only, you do not use the parenthesies or equal sign. However when using the message box as a function, you must assign a variable and use the equal sign and then the parentheses to enclose the three elements. I hope this helps rather than confuses. "Brian" wrote in message ... I have a message box that I would like to change the title of. Right now it say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? . |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
Would you help me with several other Items I am working on? I have a command
button that I want to open a file. In this line of code I only want to retrieve the WorkBook ("Master Engineering Spec.xlsm". It shows all files with the xlsm extension. Can I narroww it down to only to only Show the Document "Master Engineering Spec.xlsm"? I bet you have a better way of doing this. It seems like I took the long way and even then I see all the files with the same extention. ' Open Existing Engineer Spec 9 Control Button Private Sub Open_Existing_Engineer_Spec_9_Click() FileToOpen = Application.GetOpenFilename("Master Engineering Spec(*.xlsm), *.xlsm") If FileToOpen = False Then MsgBox ("Cannot Open File") Exit Sub End If Set bk = Workbooks.Open(Filename:=FileToOpen) End Sub Thanks "JLGWhiz" wrote: If I was doing it, I would use the ComboBox click event. I would put this code in the UserForm code module. In design mode, right click on the form and select View Code. Paste this in the code window. Private Sub Engineer_2_Click() If Me.Engineer_2.ListIndex = - 1 Then Exit Sub Else If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & Me.Engineer_2.Value Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." Titl = "C.E.S." MsgBox Msg, , Titl End If End Sub Now the code will run as soon as the user selects a name from the ComboBox. If the ComboBox has no selection, then the message box does not display. Notice also that the "e" was remove from the word "Title". That is because, Title is a reserved word that is used in the parameters portion of the message box and some other functions and methods such as InputBox. It is a good practice to avoid using reserved words for variables that might have different definitions and characteristics than those assigned in VBA source code. Have a good Christmas and New Year. "Brian" wrote in message ... I got it fixed, Thanks for all your help & Have a Merry Christmas!! "JLGWhiz" wrote: Just for clarification: The message box has three elements: 1. The message must be a string or a string variable. Strings are enclosed in quoteation marks, but the string variables are not. 2. Buttons and icons. These are optional items but the default is vbOK which puts a button with the caption "OK" on the message box display. 3. The title must be a string or string variable. When using the message box as an information medium only, you do not use the parenthesies or equal sign. However when using the message box as a function, you must assign a variable and use the equal sign and then the parentheses to enclose the three elements. I hope this helps rather than confuses. "Brian" wrote in message ... I have a message box that I would like to change the title of. Right now it say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? . . |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Meassage Box Title
The code you are using is for when you do not know the exact name of the
file you want to open. When you do know the exact name, including the file extension, and the workbook is in the current directory that your active workbook is in then you can use the syntax: Workbooks.Open Filename:="Master Engineering Spec.xlsm" or another syntax form: Workbooks.Open("Master Engineering Spec.xlsm") So your event procedure would then become: Private Sub Open_Existing_Engineer_Spec_9_Click() On Error Resume Next Workbooks.Open("Master Engineering Spec.xlsm") If Err.Number < 0 Then MsgBox "The open method failed" End If End Sub The above code will open the file if the directory path is the same as the workbook containing the calling code AND if the file extension is correct. In xl2007 the file extension is of importance because some people have the same file name with macros and without macros, each having a different file extension code. Prior to xl2007, the files would have required a different name or would have to have been in different directories. Give the above code a try to see if it works. If it does not find the file it will give you a message. "Brian" wrote in message ... Would you help me with several other Items I am working on? I have a command button that I want to open a file. In this line of code I only want to retrieve the WorkBook ("Master Engineering Spec.xlsm". It shows all files with the xlsm extension. Can I narroww it down to only to only Show the Document "Master Engineering Spec.xlsm"? I bet you have a better way of doing this. It seems like I took the long way and even then I see all the files with the same extention. ' Open Existing Engineer Spec 9 Control Button Private Sub Open_Existing_Engineer_Spec_9_Click() FileToOpen = Application.GetOpenFilename("Master Engineering Spec(*.xlsm), *.xlsm") If FileToOpen = False Then MsgBox ("Cannot Open File") Exit Sub End If Set bk = Workbooks.Open(Filename:=FileToOpen) End Sub Thanks "JLGWhiz" wrote: If I was doing it, I would use the ComboBox click event. I would put this code in the UserForm code module. In design mode, right click on the form and select View Code. Paste this in the code window. Private Sub Engineer_2_Click() If Me.Engineer_2.ListIndex = - 1 Then Exit Sub Else If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & Me.Engineer_2.Value Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." Titl = "C.E.S." MsgBox Msg, , Titl End If End Sub Now the code will run as soon as the user selects a name from the ComboBox. If the ComboBox has no selection, then the message box does not display. Notice also that the "e" was remove from the word "Title". That is because, Title is a reserved word that is used in the parameters portion of the message box and some other functions and methods such as InputBox. It is a good practice to avoid using reserved words for variables that might have different definitions and characteristics than those assigned in VBA source code. Have a good Christmas and New Year. "Brian" wrote in message ... I got it fixed, Thanks for all your help & Have a Merry Christmas!! "JLGWhiz" wrote: Just for clarification: The message box has three elements: 1. The message must be a string or a string variable. Strings are enclosed in quoteation marks, but the string variables are not. 2. Buttons and icons. These are optional items but the default is vbOK which puts a button with the caption "OK" on the message box display. 3. The title must be a string or string variable. When using the message box as an information medium only, you do not use the parenthesies or equal sign. However when using the message box as a function, you must assign a variable and use the equal sign and then the parentheses to enclose the three elements. I hope this helps rather than confuses. "Brian" wrote in message ... I have a message box that I would like to change the title of. Right now it say's Microsoft Excel Here is the code I have, but I am missing something. According to the book I have this should work. 'Greeting Message Bob Dim Title As String If Me.Engineer_2.Value = "Bozeman" Then If Time < 0.5 Then Msg = "Morning " ElseIf Time < 0.75 Then Msg = "Afternoon " Else Msg = "Evening " End If Msg = "Good " & Msg & "Mr. Bozeman" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & "Welcome to the C.E.S." MsgBox Msg Title = "C.E.S." End If Any ideas? . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Simple meassage box | Excel Programming | |||
Changing title from default | Excel Programming | |||
Can I add a Warning Meassage to a Macros Designed to Delete a Row | Excel Worksheet Functions | |||
changing the application name in the title bar | Excel Programming | |||
changing chart title via vba? | Excel Programming |