ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Double Quotes in MsgBox! (https://www.excelbanter.com/excel-programming/428011-double-quotes-msgbox.html)

Joyce

Double Quotes in MsgBox!
 
Hi,

I'm trying to copy code from personal.xls to the active workbook. Here is
part of the code: I have noted where my problem line is. I know I'm not
using the & DQUOTE properly, but can't figure it out. I have line breaks to
make the dialog box more readable, BTW...

Sub Test()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Const DQUOTE = """" ' one " character

Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents("ThisWorkbook")
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = .CountOfLines + 1
.InsertLines LineNum, "Private Sub Workbook_Open()"
LineNum = LineNum + 1
.InsertLines LineNum, "Application.DisplayAlerts = False"
LineNum = LineNum + 1
.InsertLines LineNum, "Dim oAction As Integer"
LineNum = LineNum + 1

***This is the line I'm having problems with**
.InsertLines LineNum, " oAction = MsgBox(Prompt:=" & DQUOTE &
"WILL YOU EDIT THE FILE?" & vbNewLine & vbNewLine & "Click 'YES' if opening
to EDIT" & vbNewLine & vbNewLine & "Click 'NO' if opening to VIEW or PRINT &
dquote & ", Buttons:=vbYesNo, Title:=" & dquote FILE OPEN:" & DQUOTE & ")"

LineNum = LineNum + 1

Thanks very much.

Paul E Collins

Double Quotes in MsgBox!
 
"Joyce" wrote:

[...]
"Click 'NO' if opening to VIEW or PRINT & dquote & ", Buttons:=vbYesNo,
[...]


You seem to have missed a double-quote mark after "PRINT", in order to close
the literal text and switch back to the use of the & concatenation operator.

Eq.



Jim Cone[_2_]

Double Quotes in MsgBox!
 
Dim S as Long
S = MsgBox(prompt:="WILL YOU EDIT THE FILE?" & vbNewLine & vbNewLine & _
"Click 'YES' if opening to EDIT" & vbNewLine & vbNewLine & _
"Click 'NO' if opening to VIEW or PRINT", Buttons:=vbYesNo, Title:=" FILE OPEN:")
--
Jim Cone
Portland, Oregon USA



"Joyce"
wrote in message
Hi,
I'm trying to copy code from personal.xls to the active workbook. Here is
part of the code: I have noted where my problem line is. I know I'm not
using the & DQUOTE properly, but can't figure it out. I have line breaks to
make the dialog box more readable, BTW...
-snip
***This is the line I'm having problems with**
.InsertLines LineNum, " oAction = MsgBox(Prompt:=" & DQUOTE &
"WILL YOU EDIT THE FILE?" & vbNewLine & vbNewLine & "Click 'YES' if opening
to EDIT" & vbNewLine & vbNewLine & "Click 'NO' if opening to VIEW or PRINT &
dquote & ", Buttons:=vbYesNo, Title:=" & dquote FILE OPEN:" & DQUOTE & ")"

LineNum = LineNum + 1

Thanks very much.

Joyce

Double Quotes in MsgBox!
 
Thanks for your help. I noticed another one I had forgotten, but was
reassured to know I was on the write path!



"Paul E Collins" wrote:

"Joyce" wrote:

[...]
"Click 'NO' if opening to VIEW or PRINT & dquote & ", Buttons:=vbYesNo,
[...]


You seem to have missed a double-quote mark after "PRINT", in order to close
the literal text and switch back to the use of the & concatenation operator.

Eq.




Joyce

Double Quotes in MsgBox!
 
I spoke too soon... Here is the updated code. It results in the first line
being copied into the active workbook -it ignores the rest, so I must again
be doing something wrong.

oAction = MsgBox(Prompt:="WILL YOU EDIT THE FILE?"

..InsertLines LineNum, " oAction = MsgBox(Prompt:=" & DQUOTE & "WILL YOU EDIT
THE FILE?" & DQUOTE & vbNewLine & vbNewLine & DQUOTE & "Click 'YES' if
opening to EDIT" & DQUOTE & vbNewLine & vbNewLine & DQUOTE & "Click 'NO' if
opening to VIEW or PRINT" & DQUOTE & ", Buttons:=vbYesNo, Title:=" & DQUOTE &
"FILE OPEN:" & DQUOTE & ")"

Thanks very much.

"Paul E Collins" wrote:

"Joyce" wrote:

[...]
"Click 'NO' if opening to VIEW or PRINT & dquote & ", Buttons:=vbYesNo,
[...]


You seem to have missed a double-quote mark after "PRINT", in order to close
the literal text and switch back to the use of the & concatenation operator.

Eq.




Jim Cone[_2_]

Double Quotes in MsgBox!
 
And if you actually want to put all the text inside quote marks then...

Dim oAction
Dim DQUOTE As String
DQUOTE = Chr$(34)

oAction = MsgBox(Prompt:=DQUOTE & "WILL YOU EDIT THE FILE?" & _
DQUOTE & vbNewLine & vbNewLine & DQUOTE & _
"Click 'YES' if opening to EDIT" & DQUOTE & vbNewLine & _
vbNewLine & DQUOTE & "Click 'NO' if opening to VIEW or PRINT" & _
DQUOTE, Buttons:=vbYesNo, Title:=DQUOTE & "FILE OPEN:" & DQUOTE)

--
Jim Cone
Portland, Oregon USA



All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com