我将开发一个简单的应用程序,该应用程序将更新工作簿中的数据,该数据将链接到外部工作而无需访问excel应用程序。现在,当数据链接到受保护的外部源时尝试更新数据时,我遇到了问题。它提示我在运行开发的应用程序时需要输入密码。我想通过在开发的应用程序的脚本中输入密码来跳过此密码提示对话框。我应该在脚本中跳过密码提示怎么办?
string strFileName = filename;
Excel.Workbook readBook = null;
object missing = System.Reflection.Missing.Value;
Excel.ApplicationClass readApp = new Excel.ApplicationClass();
readBook = readApp.Workbooks.Open(strFileName, 3, false, missing, "1234", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
Array links = (Array)readBook.LinkSources(Excel.XlLink.xlExcelLinks);
if (links != null)
{
for (int i = 1; i <= links.Length; i++)
{
readBook.UpdateLink((string)links.GetValue(i),
Excel.XlLinkType.xlLinkTypeExcelLinks);
}
readApp.DisplayAlerts = false;
readBook.SaveAs(filename, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing,
false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
else
{
MessageBox.Show("The workbook contains no links to " +
"other workbooks.");
}
我希望结果是当使用密码将工作簿链接到外部工作簿时,无需输入密码即可更新工作簿,但是 实际结果是我必须在运行应用程序时在提示对话框中输入密码