Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-21-2023, 06:22 AM
MartinGM MartinGM is offline Declaring a Constant Windows 11 Declaring a Constant Office 2021
Competent Performer
Declaring a Constant
 
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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring a Constant Declare Constant for Chr(14) VBorNotVB Word VBA 3 12-06-2020 09:28 PM
Declaring Public variables and accessing in other modules rekent Word VBA 16 11-24-2020 02:09 PM
Declaring a Constant Declaring a variable that is known across modules Officer_Bierschnitt Excel Programming 5 11-18-2015 12:28 PM
Declaring a Constant Keep cell in formula constant jprt68 Excel 1 06-26-2012 08:31 AM
Declaring a Constant Keeping the top row constant in Excel MSmand Excel 2 07-13-2011 01:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft