寻 zswang(伴水清清)(专家门诊清洁工) + 问题:在excel 宏里设置保护密码
if(fd.FileName!=string.Empty)
{
oBook = oBooks.Open(fd.FileName, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
CodeModule vCodeModule = oExcel.ActiveWorkbook.VBProject.VBComponents.Add(
vbext_ComponentType.vbext_ct_StdModule).CodeModule;
//这里宏代码就可以放到配置文件里了
vCodeModule.AddFromString(@ "
Sub DefinitedMacro()
Columns( " "A:A " ").Select
Selection.Columns.AutoFit
ActiveSheet.Protection.AllowEditRanges.Add Title:= " "区域1 " ", Range:=Columns( _
" "D:F " ")