Skip to content

Word.Range Search returns Range or RangeCollection online, but only RangeCollection on Desktop (PC and Mac) #5510

Open
@dweill

Description

@dweill

Provide required information needed to triage your issue

When getting a document selection and performing a search

range.search('hello')

If there is only one instance of the search text in the document, Range.search returns a Range for the online version, but a RangeCollection for desktop. If there are multiple matches it correctly returns a RangeCollection, per the api documentation

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: Office on the web
  • Host [Excel, Word, PowerPoint, etc.]: Word
  • Office version number: latest
  • Operating System: Mac
  • Browser (if using Office on the web): Chrome

Expected behavior

I would expect that calling the Range.search method returns a RangeCollection both online and on desktop versions of the office js api.

Current behavior

Currently, in the online version of the office js api, Range.search returns a RangeCollection OR a Range (if there is only one match)

An improvement would be for it to always return a RangeCollection or note the different behavior on the web in the documentation

Steps to reproduce

  1. Using office on the web (Word) perform a search on a range (Range.search) for text that appears only once in the document
  2. await context.sync();
  3. log the result.
  4. see that it logs a Range, and not the expected RangeCollection

Link to live example(s)




Provide additional details




Context

Useful logs

  • Console errors
  • Screenshots
  • Test file (if only happens on a particular file)

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

Metadata

Metadata

Labels

Area: WordIssue related to Word add-insNeeds: attention 👋Waiting on Microsoft to provide feedback

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions