我寫了這個代碼,但得到一個錯誤:VB接取創建在使用範圍內的每個範圍從Excel
Function getFileRange(ByVal objFilePath As String) As String
Dim xlApp As Object
Dim xlWb As Object
Dim xlSheet As Object
Dim rng As Object
Dim usedRng As Variant
Set xlApp = CreateObject("Excel.Application")
Set xlfile = xlApp.Workbooks.Open(objFilePath)
Set xlSheet = xlfile.Sheets(1)
usedRng = xlSheet.usedRange.Address
getFileRange = Replace(usedRng, "$", "")
For Each rng In usedRng
If rng.MergeCells Then
With rng.MergeArea
.UnMerge
.Formula = rng.Formula
End With
End If
Next
Debug.Print getFileRange
Workbooks.Close True
Set xlApp = Nothing
Set xlfile = Nothing
Set xlSheet = Nothing
End Function
如何界定RNG的範圍在Excel中?任何參考,我可以瞭解有關在vb訪問轉換excel vb? (我不知道你是怎麼說的,我需要知道很多關於在訪問中創建excel應用程序的情況,反之亦然)
'昏暗的RNG作爲Range' – Vityata