Why does "Azure Information Protection" popup pause the MATLAB script when I use "actxserver" ?

16 visualizaciones (últimos 30 días)
I am using "actxserver('Powerpoint.Application')" to create a PowerPoint object and use "actxGetRunningServer" to save the final PPT file. It is in this last step that causes a sensitivity label issue.
During the process of saving the PPT file using "actxGetRunningServer" to get the active application and use it to save the final PPT file, a Microsoft Azure Information Protection sensitivity label popup appears asking me to make a sensitivity label selection. This auto popup is not needed and causes our work to pause there forever if no option is selected.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 28 de Nov. de 2022
Microsoft Azure Information Protection controls and helps secure documents and sensitive data through embedded labels and permissions. Azure Information Protection is often imposed by a company's IT network department which also often imposes the requirement for all documents to be saved with an accompanying sensitivity label.
The following MATLAB line creates and saves a new PowerPoint file, but since Microsoft Azure Information Protection enforces all documents be saved with a sensitivity label, a popup appears asking users to add a sensitivity label.
actxserver('Powerpoint.Application').ActivePresentation.SaveAs('<filename>');
Windows Script Host can be used to deal with the popup through automated keystrokes. Once the popup appears, the Windows Script Host automated keystrokes will close out of the popup which will allow the MATLAB script to continue.
First, create a new PowerShell script in your project directory and name is something similar to "closePopup.ps1". Then add the following lines of code to the script.
$wsh = New-Object -ComObject WScript.Shell
$activated = $false
while($activated -eq $false)
{
$activated = $wsh.AppActivate('Microsoft Azure Information Protection');
}
$wsh.SendKeys("{TAB}{TAB}{TAB}{BS}{DOWN}{ENTER}{ENTER}{DOWN}{ENTER}{ENTER}");
Next, in your MATLAB script, add the following line of code before saving the PowerPoint file:
system("powershell -file closePopup.ps1 && exit &");

Más respuestas (1)

Image Analyst
Image Analyst el 8 de Jun. de 2023
Here is a way you can do it all from the Excel ActiveX server, instead of using that separate file and calling PowerShell as the provided answer shows. Change the workbook name for your situation.
% Test to set the Microsoft Azure Information Protection label on an Excel workbook.
% Reference support article:
% https://www.mathworks.com/matlabcentral/answers/1901140-why-does-azure-information-protection-popup-pause-the-matlab-script-when-i-use-actxserver?s_tid=ta_ans_results
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format compact;
% Define your workbook file name.
excelFullFileName = fullfile(pwd, '\testAIP.xlsx');
% Make sure it exists. Open Excel as an ActiveX server if it does.
if isfile(excelFullFileName)
% If the workbook exists, launch Excel as an ActiveX server.
Excel = actxserver('Excel.Application');
Excel.visible = true; % Make the server visible.
fprintf('Excel opened successfully.\n');
fprintf('Your workbook file exists:\n"%s".\nAbout to try to open it.\n', excelFullFileName);
% Open up the existing workbook named in the variable fullFileName.
Excel.Workbooks.Open(excelFullFileName);
fprintf('Excel opened file successfully.\n');
else
% File does not exist. Alert the user.
warningMessage = sprintf('File does not exist:\n\n"%s"\n', excelFullFileName);
fprintf('%s\n', warningMessage);
errordlg(warningMessage);
return;
end
% If we get here, the workbook file exists and has been opened by Excel.
% Ask Excel for the AIP label of the workbook we just opened.
label = Excel.ActiveWorkbook.SensitivityLabel.GetLabel
% See if there is a label already. If not, these will be null:
existingLabelID = label.LabelId
existingLabelName = label.LabelName
% Create a label.
label = Excel.ActiveWorkbook.SensitivityLabel.CreateLabelInfo
label.LabelId = "a518e53f-798e-43aa-978d-c3fda1f3a682";
label.LabelName = "Business Use";
% Assign the label to the workbook.
Excel.ActiveWorkbook.SensitivityLabel.SetLabel(label, label);
% Save this workbook with the new AIP setting we just created.
Excel.ActiveWorkbook.Save;
% Shut down Excel.
Excel.ActiveWorkbook.Close;
Excel.Quit;
% Excel is now closed down. Delete the variable from the MATLAB workspace.
clear Excel;
% Now check to see if the AIP label has been set
% by opening up the file in Excel and looking at the AIP banner.
winopen(excelFullFileName)

Categorías

Más información sobre Data Export to MATLAB en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by