[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

MS Word, VB6 and VBA: How set a custom flag/object/property/tag to a Range object?

Is there a way to assign a user defined something like flag/object/property/tag to a Range object?
Does the Range object has some unused property of Variant/String/Object type which the user could use for its on purpose?

In VB6 for instance, controls have the Tag (string) property, which is not used by VB6 by default, and it can be used for any purpose, such as assigning some data to that control.

So, is there some equivalent for the Range object?
0
npaun
Asked:
npaun
  • 3
  • 3
  • 2
1 Solution
 
SimonCommented:
I'd think not. A control is a persistent object whose properties can be written to file, whereas a range is an ephemeral one.
0
 
DrTribosCommented:
I think you might have to look at bookmarks or content controls
0
 
SimonCommented:
For Word there are custom document properties that you can create/edit/delete.
For Excel there is the names collection and cells can be assigned an ID:
"Returns or sets a String value that represents the identifying label for the specified cell when the page is saved as a Web page."
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
npaunAuthor Commented:
@SimonAdept
You mean CustomDocumentProperties? If I understated correctly, they are document level properties, while I need it for Range object (e.g. selections, Words...)
0
 
SimonCommented:
There is the range.comment object which is part of the tracked changes/review document process.

Selection.Comments.Add Range:=Selection.Range

This creates a review comment that is associated with the range (word, phrase, paragraph) that you want.

You can then do various things with the comment and/or the range it refers to.

Sub test()
Dim myRange As Range
If ActiveDocument.Comments.Count >= 1 Then
    For x = 1 To ActiveDocument.Comments.Count
    Set myRange = ActiveDocument.Comments(x).Range
    Debug.Print myRange, myRange.Start, myRange.End
    myRange.Select
    Next x
End If
End Sub
0
 
npaunAuthor Commented:
@SimonAdept
Thanks for the reply. Yes, I know for the comment property, however it has internal use by Word, and all entries here would be seen in the user comments selection, i.e. these entries would interfere with comments manually and explicitly added by the user itself... I would need a Range property that is "unused" and would not so easily interfere with Word...
0
 
npaunAuthor Commented:
@DrTribos
Thank for the post.
Unfortunately, the ContentControls also severely interfere with the Word normal behavior, it, as intended, ads clearly visible controls in the text...
0
 
DrTribosCommented:
Yup, aside from that i think it is bookmarks.

Other approaches that I can think of would be very 'hacky'...

1. Delineate range via a portfolio of uniquely named styles all with the same appearance
2. Delineate using table cell
3. Delineate using field codes

But as far as I know bookmarks is the go
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now