Why do I get a "SaveAs method of Workbook class failed" error when using the 'xlswrite' function?

조회 수: 40 (최근 30일)
I received some code from a colleague which calls 'xlswrite', but it errors with the following message:
Error using xlswrite (line 226)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: SaveAs method of Workbook class failed
Help File: xlmain11.chm
Help Context ID: 0
Why does this occur, and how can I work around this issue?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2018년 6월 29일
This can occur if the directory you are trying to write to does not exist, or if you don't have write access to that directory. While you can "write" to files which don't previously exist (MATLAB will create them), the directory does need to exist beforehand.
This can also happen in some situations where the user which starts the Excel is a system user. Excel expects the existence of the Desktop directory. To enable the command to work try the following:
For x64 processes create the following folder:
C:\Windows\SysWOW64\config\systemprofile\Desktop
For x86 processes create the following folder:
C:\Windows\System32\config\systemprofile\Desktop

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by