Bold text

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,375
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a message box that is displayed if another user already has a file open on my network. I want to make the text within the message box bold "without saving them". Could someone tell me how I do this please?

VBA Code:
Private Sub Workbook_Open()
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
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Can't be done in a MsgBox.....you would have to create a Forms box !!
 
Upvote 0
Does that do the same thing as a message box? If so, how would I put one in?
 
Upvote 0
This forms textbox will be created on the activesheet and be deleted after 10 seconds. Size and position of the box as well as the dwell time on the sheet can be changed to suit.
VBA Code:
Sub testTextBx()
Dim Tbx As Shape
strLine = "Joe"
Set Tbx = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 60, 40, 120, 120)
With Tbx.TextFrame.Characters
    .Text = "The following user has the allocation sheets open: " & strLine & vbCrLf & vbCrLf & _
            "This message will be removed in 10 seconds."
    .Font.Bold = True
    Application.ScreenUpdating = True
    Application.Wait Now + TimeSerial(0, 0, 10)
    Tbx.Delete
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,575
Members
452,652
Latest member
eduedu

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