Lose access to clipboard when computer is locked

19 ビュー (過去 30 日間)
Duncan Campbell
Duncan Campbell 2019 年 7 月 2 日
編集済み: michal.markun 2025 年 9 月 2 日 13:31
I have a script I use to process model simulation data and then plot results to PowerPoint using activeX.
Recently, after switching from Windows 7 to 10, I have noticed that if I lock my computer, not hibernate or sleep, the script will continue to run and generate the PowerPoint file. The only problem is that the plots have not been populated however the correct number of slides and slide titles are present.
Here is how I am running activeX:
copyfile('TEMPLATE.pptx',Fname)
p = actxserver('Powerpoint.Application');
pp = p.Presentations.Open(Fname); % open file copied from template
slide_H = pp.PageSetup.SlideHeight;
slide_W = pp.PageSetup.SlideWidth;
ps = pp.Slides;
pT = ps.Item(2);
pTs = pT.Shapes;
pT.Duplicate;
slide = 3;
pc = ps.Item(slide);
set(pc.Shapes.Item(1).TextFrame.TextRange,'Text','SLIDE TITLE')
% following is loops for each plot to be made
plot()
hgexport(gcf,'-clipboard');
pic = invoke(pc.Shapes,'Paste')
set(pic,'Width',0.95*slide_W)
set(pic,'Left',(slide_W-get(pic,'Width'))/2)
%
invoke(pp,'Save')
p.Quit();
p.delete;
using Matlab 21018b

回答 (2 件)

Alexandre3
Alexandre3 2019 年 11 月 25 日
編集済み: Alexandre3 2019 年 11 月 25 日
Hi Duncan,
I have exactly the same problem when the computer is locked with windows 10.
My code plots the results from simulation data and then exports the figure to Excel. But when the computer is locked, my code crashes because matlab has no access to the clipboard.
Please let me know if you found a solution.
Best,

michal.markun
michal.markun 2025 年 9 月 2 日 13:08
編集済み: michal.markun 2025 年 9 月 2 日 13:31
Hi,
I have the same problem. The below simplified code (copy it to your Matlab, online doesn't work) works well when the computer is NOT locked. When the screen-saver is on, then I get:
Error using copygraphics
cannot open system clipboard
java.lang.IllegalStateException: cannot open system clipboard
pause(5) %remove security card / turn on screen-saver for a moment
fig=figure;
imagesc(magic(5));
copygraphics(fig);
%rest goes through if screen-saver is off:
Excel = actxserver('Excel.Application');
op = invoke(Excel.Workbooks,'Add');
Sheets = Excel.ActiveWorkBook.Sheets;
target_sheet = Excel.ActiveWorkBook.Worksheets.Add();
target_sheet.Name = 'Sheet1';
invoke(target_sheet, 'Activate');
Activesheet = Excel.Activesheet;
Paste(Activesheet,get(Activesheet,'Range','A1','A1'))
set(Excel, 'Visible', 1);

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by