Excel调用被被调用者错误拒绝

时间:2016-05-18 20:00:39

标签: excel excel-vba vbscript vba

我已经编写了一个基本上在后台打开Excel的vbs,在其上运行一个宏,然后通过将一个单元格的值附加到它的名称来保存它。但是,这种情况有时只会发生,我在粗体线上出现错误......

  

行:23
  Char:3
  错误:被叫方拒绝了来电   代码:80010001
  资料来源:( null)

Option Explicit

ExcelMacroExample

Sub ExcelMacroExample() 

  Dim objExcel  
  Dim objApp  
  Dim objWorkbook
  Dim objSheet
  Dim SI
  Dim scriptdir
  Dim oFSO
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  scriptdir = oFSO.GetParentFolderName(WScript.ScriptFullName)

  Set objExcel = CreateObject("Excel.Application")
  Set objWorkbook = objExcel.Workbooks.Open(scriptdir & "\SCORECARD.xlsm")

  objExcel.Run "RefreshConns"
  WScript.Sleep 90000 

  Set objSheet = objWorkbook.Worksheets("Cover")

  SI = objSheet.Cells(4, 2).Value

  objExcel.ActiveWorkbook.SaveAs scriptdir & "\Scorecards\" & "SCORECARD_" & SI & "_" & Year(Now()) & Month(Now()) & Day(Now()) & "_" & Hour(Now()) & Minute(Now()) &".xlsm", 52

  objExcel.ActiveWorkbook.Close
  objExcel.Quit   

  MsgBox("Successfully generated profiling scorecard.")

End Sub

0 个答案:

没有答案