Can you have a line break in a message box

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Is it possible to have a line break in a message box or increase the font size of some of the text? I have this vba and I want to emphasize the Without saving them part.

VBA Code:
Sub Workbook_Open()

'lastrow = sht.ListObjects("Table1").Range.Rows.Count

'Worksheets("home").Unprotect Password:="costings"

Application.WindowState = xlMaximized

Dim file1 As Integer
Dim strLine As String
file1 = FreeFile
    If Not ActiveWorkbook.ReadOnly = True Then
        'only add name to the usage log if the user has it locked
        Open ThisWorkbook.Path & "\usage.log" For Append As #file1
        Print #file1, Environ("USERNAME") & ". Please close all the additional workbooks that will be opened " _
        & "without saving them. Then contact the user that has it open or wait until they are finished."
        Close #file1
    Else
        'if someone else has the file open, find out who
        Open ThisWorkbook.Path & "\usage.log" For Input Access Read As #file1
            Do While Not EOF(file1)
               Line Input #file1, strLine
            Loop
        Close #file1
        MsgBox "The following user has the allocation sheets open: " & strLine
    End If



'Sheets("home").Shapes("txtName").TextFrame.Characters.Text = "Type sheet name here."

'Worksheets("home").txtDirectCombo.Value = Worksheets("home").txtDirectMonth.Value & " " & Worksheets("home").txtDirectYear.Value







'Worksheets("home").Protect Password:="costings"

End Sub
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You can't increse Font Size in a MsgBox, they are set by your sytem.....To insert a line break use
VBA Code:
MsgBox "WARNING" & vbCrLf & "This is an Important Message!"
 
Upvote 0
I changed my code and now all that gets displayed is this

1599784651021.png


VBA Code:
Dim file1 As Integer
Dim strLine As String
file1 = FreeFile
    If Not ActiveWorkbook.ReadOnly = True Then
        'only add name to the usage log if the user has it locked
        Open ThisWorkbook.Path & "\usage.log" For Append As #file1
        Print #file1, Environ("USERNAME") & ". Please close all the additional workbooks that will be opened " _
        & vbCrLf & "WITHOUT SAVING THEM." & vbCrLf & "Then contact the user that has it open or wait until they are finished."
        Close #file1
    Else
        'if someone else has the file open, find out who
        Open ThisWorkbook.Path & "\usage.log" For Input Access Read As #file1
            Do While Not EOF(file1)
               Line Input #file1, strLine
            Loop
        Close #file1
        MsgBox "The following user has the allocation sheets open: " & strLine
    End If
 
Upvote 0
Try using
VBA Code:
If Not ActiveWorkbook.ReadOnly = True Then
        'only add name to the usage log if the user has it locked
        'Open ThisWorkbook.Path & "\usage.log" For Append As #file1
        MsgBox Environ("USERNAME") & ". Please close all the additional workbooks that will be opened " _
        & vbCrLf & "WITHOUT SAVING THEM." & vbCrLf & "Then contact the user that has it open or wait until they are finished."
        Close #file1
    Else
 
Upvote 0
But that won't let me see the user that is using the file, will it?
 
Upvote 0
I need to have all the same functionality that the code in message 1 allows.
 
Upvote 0
If I comment out
VBA Code:
'Open ThisWorkbook.Path & "\usage.log" For Append As #file1
I get an error saying bad file name or number
 
Upvote 0
Sorry Dave I only commented that line out so I could test the code
VBA Code:
If Not ActiveWorkbook.ReadOnly = True Then
        'only add name to the usage log if the user has it locked
        Open ThisWorkbook.Path & "\usage.log" For Append As #file1
        MsgBox Environ("USERNAME") & ". Please close all the additional workbooks that will be opened " _
        & vbCrLf & "WITHOUT SAVING THEM." & vbCrLf & "Then contact the user that has it open or wait until they are finished."
        Close #file1
    Else
 
Upvote 0
Are you suggesting I should try the above code?
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top