Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-03-2020, 01:05 PM
VBorNotVB VBorNotVB is offline Declare Constant for Chr(14) Mac OS X Declare Constant for Chr(14) Office 2016 for Mac
Novice
Declare Constant for Chr(14)
 
Join Date: Oct 2018
Location: Southern California
Posts: 25
VBorNotVB is on a distinguished road
Default Declare Constant for Chr(14)


Word has built-in constants such as vbCr = Chr(13) and vbFormFeed = Chr(12).
How can I declare my own constant vbColumnBreak = Chr(14)?

Word VBA compiler objects to "Chr" in the following declaration:
public const vbColumnBreak as string = Chr(14)
Reply With Quote
  #2  
Old 12-05-2020, 03:36 PM
macropod's Avatar
macropod macropod is offline Declare Constant for Chr(14) Windows 10 Declare Constant for Chr(14) Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Check the WdBreakType Enumeration in the VBA Help file:

Const wdColumnBreak As Long = 8
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-06-2020, 07:38 PM
Guessed's Avatar
Guessed Guessed is offline Declare Constant for Chr(14) Windows 10 Declare Constant for Chr(14) Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I think the usefulness of constant depends on how you intend to use it. Assuming we assign the value as 8, then these two lines yield significantly different results.

Selection.InsertBreak Type:=8
Selection.TypeText 8

I assumed that VBorNotVB was looking to include the break as a character so it could be included in strings inserted into ranges or selections.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 12-06-2020, 09:28 PM
macropod's Avatar
macropod macropod is offline Declare Constant for Chr(14) Windows 10 Declare Constant for Chr(14) Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If one develops code using early binding, which allows the use of Word constants, but needs to distribute the code using late binding, declaring the constants allows their names to be retained in the code.

Amongst other things, that also makes it easier to see what the late-bound code is doing.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declare wBk as workbook. Set wBk = workbooks("NewBook.xls") gives error: Subscript out of range. Syed Shabbir Excel Programming 1 09-27-2020 09:35 AM
constant request for password for Outlook.com workingmom Outlook 0 10-20-2016 12:37 PM
Constant Request for Server Passwords danpbphoto Outlook 1 01-12-2015 07:28 AM
Declare Constant for Chr(14) Keep cell in formula constant jprt68 Excel 1 06-26-2012 08:31 AM
Declare Constant for Chr(14) 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 12:32 AM.


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