Can you have a line break in a message box

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,837
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:

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,462
Office Version
  1. 2013
Platform
  1. Windows
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!"
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,837
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
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,462
Office Version
  1. 2013
Platform
  1. Windows
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
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,837

ADVERTISEMENT

But that won't let me see the user that is using the file, will it?
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,837
I need to have all the same functionality that the code in message 1 allows.
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,837

ADVERTISEMENT

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
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,462
Office Version
  1. 2013
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,269
Messages
5,571,234
Members
412,372
Latest member
JON_ROCKS
Top