View Single Post
 
Old 05-21-2023, 06:22 AM
MartinGM MartinGM is offline Windows 11 Office 2021
Competent Performer
 
Join Date: May 2023
Location: England
Posts: 108
MartinGM is on a distinguished road
Default Declaring a Constant

I understand how to declare a Public Constant and set its value eg . . .

Public Const <name> as String = <value>

However I want to define the value as a concatenated string eg . . .

Public Const <name> as String = "C:\Users" & Environ$("username") & "\OneDrive"

. . . but this fails with "Compile error".

I can get round this by just declaring the constant's name, then setting its value in the Auto-Open macro.

I was wondering if there is a better or neater way to do this ?
Reply With Quote