My client wants me to look into the possibility of not allowing regular users to be able to print and edit excel/csv files they download from our website. I have been able to successfully prevent users from editing csv/excel files but with regards to denying printing of the csv/excel files, is there any support by aspose regarding this? I couldn’t find anything from the available documentation any help would be appreciated thanks.
@DXHoe
You can prevent printing files by writing VBA code. Please refer to the attachment (96.7 KB).
The sample code is as follows:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Refusing to print in paperless office"
End Sub
You can also create template files and modify the VBA content in the template using Aspose. Cells. Please refer to the following documents.
https://docs.aspose.com/cells/net/manage-vba-project/
Hope helps a bit.
It definitely does help thank you very much
@DXHoe,
You are welcome. Thank you for your feedback. If you have any questions, please feel free to contact us.
@DXHoe,
By using the Aspose.Cells APIs, you can also directly set VBA code that prevents printing.
The sample code is as follows:
Workbook wb = new Workbook("data.xlsx");
VbaModuleCollection modules = wb.VbaProject.Modules;
modules["ThisWorkbook"].Codes = "Private Sub Workbook_BeforePrint(Cancel As Boolean)\r\n Cancel = True\r\n MsgBox \"Refusing to print in paperless office\"\r\nEnd Sub\r\n";
wb.Save("data_out.xlsm");
Hope helps a bit.