Thread: Msg Box Title
View Single Post
  #3   Report Post  
Gene Haines Gene Haines is offline
Junior Member
 
Posts: 21
Default

Quote:
Originally Posted by Walter Briscoe View Post
In message of Sat, 2 Mar 2013
01:33:02 in microsoft.public.excel.newusers, Gene Haines <Gene.Haines.b7
writes

Totally new to VBA. I have pasted a VBA code and was wondering how I
can
keep the MsgBox Title consistent throughout the VBA procedure. I have
the following code but when the ans = vbno, the MsgBox Title is
Microsoft Excel and not Metals Inventory Database. any help would be
greatly appreciated.


The OP might like to adapt what I show below AS I have adapted what he
has written.

Option Explicit ' All modules should start so to avoid some bugs


Private Function MIDMsg(ByVal Msg As String, Optional ByVal Config As Long = 0) As Long
Const Title As String = "Metals Inventory Database"

MIDMsg = MsgBox(Msg, Config, Title)
End Function

Public Sub foo()
Dim Msg As String

If True Then
Msg = "You owe a balance due to Virginia at this time!" & _
vbLf & vbLf & _
"Would you like to fufill that obligation" & _
" with an Funds Transfer?"
' Brackets in call statements seem odd to me
If MIDMsg(Msg, vbYesNo + vbQuestion) = vbYes Then
' Use call if you really want to have brackets
Call Workbooks.Open("C:\Documents and Settings\MyFolder\My Documents\TestII.xlsx")
Else
' Or leave them out for textual economy.
MIDMsg "Then please do a Journal Voucher. Thank you."
End If
Else
' I have corrected a slip.
MIDMsg "No B[a]lance Owed"
End If

End Sub

Thank you


You're welcome. I found your problem entertaining.
N.B. my long lines may wrap in an unfriendly way.
--
Walter Briscoe
Thank you Walter: I will set this up.

Regards

Gene