OfficeDev / office-js

A repository for issues related to the Office JavaScript APIs and Office Add-ins platform. Find the Office.js library in Office.js CDN: https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
725 stars 106 forks source link

RichApi.Error: GeneralException still occurs when call insertFileFromBase64 in document 'Viewing' mode #5484

Open NataliaKravcheniaTR opened 1 month ago

NataliaKravcheniaTR commented 1 month ago

When document is in 'Viewing' mode, insertFileFromBase64 throws GeneralException exception

Your Environment

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

Expected behavior

When document is in 'Viewing' mode, insertFileFromBase64 throws ReadOnlyException (that we can identify that document is read-only) instead of GeneralException exception

Current behavior

When document is in 'Viewing' mode, insertFileFromBase64 throws GeneralException exception

Steps to reproduce

  1. Open document in 'Viewing' mode
  2. Call await context.document.insertFileFromBase64(base64, "Replace"); Image

Office.context.document.mode always returns 'readWrite' Document.getActiveViewAsync is not working in Word.

github-actions[bot] commented 1 month ago

Here are some similar issues that might help you. Please check if they can solve your problem.

Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Solution 1:

FYI it looks like this was related to my version of Word. After updating to 2304 I no longer get the error.

Reference:

Reference:

Powered by issue-sentinel

NataliaKravcheniaTR commented 1 month ago

These issues are not related to mine.

penglongzhaochina commented 1 month ago

Hi @NataliaKravcheniaTR Are you working on Word online or Word desktop?

NataliaKravcheniaTR commented 1 month ago

@penglongzhaochina Word Desktop

penglongzhaochina commented 1 month ago

Hi @NataliaKravcheniaTR ,

The viewing mode means that we can only read the file but not edit the file. Any inserted operation not been allowed no matter from human manually or add-in inserted. All the inserting operation from addin will throw exception not only "insertfilefrombase64". Thank you.

NataliaKravcheniaTR commented 1 month ago

Yes, I understand that, but can it be more specific exception instead of GeneralException? Or could we check that document is in 'Viewing' mode? I've tried Office.context.document.mode but it returns readWrite' when a document is in Viewing or Editing mode

penglongzhaochina commented 1 month ago

Thanks for reporting this issue.
It has been put on our backlog<Bug#9898914> for internal track. We will keep track of this issue and let you know if there are any updates.