另外,我在这部分遇到了一个运行时错误 1004: Method of Object Failed:
如果是 vb6,那么您需要指定完整的参考。例如。
Private Sub Sample()
Dim oXLApp As Object, oXLWB As Object, oXLSht As Object
Dim iCtrRow As Long
'~~> Establish an EXCEL application object
On Error Resume Next
Set oXLApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set oXLApp = CreateObject("Excel.Application")
End If
Err.Clear
On Error GoTo 0
oXLApp.Visible = True
'~~> Open the relevant file
Set oXLWB = oXLApp.Workbooks.Open("C:\Book1.xls")
'~~> Change (1) to the relevant sheet
Set oXLSht = oXLWB.Worksheets(1)
iCtrRow = 1
'~~> iCtrRow
oXLSht.Range("I" & iCtrRow).NumberFormat = "#,##0.00000"
End Sub
如果你是在 VBA 中做的,它会是这样的
Private Sub Sample()
Dim oXLWB As Workbook, oXLSht As Worksheet
Dim iCtrRow As Long
'~~> Open the relevant file
Set oXLWB = Workbooks.Open("C:\Book1.xls")
'~~> Change (1) to the relevant sheet
Set oXLSht = oXLWB.Worksheets(1)
iCtrRow = 1
'~~> iCtrRow
oXLSht.Range("I" & iCtrRow).NumberFormat = "#,##0.00000"
End Sub
关于分析工具库,您能否显示有关如何激活它并使用“MDURATION”公式的确切 vb6 代码。