Ask Your Question

[macro] Global constant for special character [closed]

asked 2015-03-13 17:37:14 +0200

LibreGuy gravatar image


Recently I learned how to create global constants. Great! However ... there is a small problem.

Some special characters in texts need to be created by using the chr() function. For example I use chr(8220) to create double left quotes and chr(8221) to create double right quotes. Now if I want to quote something in a text I do it like this:

MsgBox("Hello " & chr(8220) & "John" & chr(8221) & ".")

This is not very readable, so I wanted to use constants:

REM Top op Document
Global Const LQ = chr(8220)
Global Const RQ = chr(8221)

REM Somewhere else in the document
MsgBox("Hello " & LQ & "John" & RQ & ".")

However, this is not working because assigning the chr() function to a constant is not accepted and results in an error. Is there another way to globally assign special characters? Help needed ...

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-17 15:52:46.682399

2 Answers

Sort by » oldest newest most voted

answered 2015-03-13 17:53:37 +0200

karolus gravatar image


 Global Const LQ = "“"
 Global Const RQ = "”"
edit flag offensive delete link more

answered 2015-03-13 18:01:15 +0200

LibreGuy gravatar image

Thank you very much Karolus!

Can I also assign a linebreak that way? Currently I use chr(13) for a line break (new line). I would like to assign that to a constant as well. Is that possible?

edit flag offensive delete link more


if change to serious programming language, you will never have thus silly problems.

karolus gravatar imagekarolus ( 2015-03-13 18:30:45 +0200 )edit

True, but it doesn't answer my question ;)

Can I somehow assign these linebreak to a constant or variable which I can use in all macro's (subs)?

Something like this:

Global Const BREAK = chr(13) & chr(13)

Can it somehow be done?

LibreGuy gravatar imageLibreGuy ( 2015-03-13 22:11:19 +0200 )edit

It answer your question because nobody force you to stumble with basic!

karolus gravatar imagekarolus ( 2015-03-14 00:01:57 +0200 )edit

Question Tools

1 follower


Asked: 2015-03-13 17:37:14 +0200

Seen: 387 times

Last updated: Mar 13 '15