Dim xl As New Excel.Application Dim xlBook As Workbook Set xl = GetObject(, "Excel.Application") Set xlBook = xl.ActiveWorkbook Debug.Print xlBook.Path & "\" & xlBook.Name
Dim str1 As String,str2 as string str1 = Application.ActiveWorkbook.FullName str2 = ThisWorkbook.Path 其中,str1得到的是带有文件名的路径名,str2得到的是路径名。如: str1="e:\test\book1.xls" str2="e:\test"
Dim xlBook As Workbook
Set xl = GetObject(, "Excel.Application")
Set xlBook = xl.ActiveWorkbook
Debug.Print xlBook.Path & "\" & xlBook.Name
str1 = Application.ActiveWorkbook.FullName
str2 = ThisWorkbook.Path
其中,str1得到的是带有文件名的路径名,str2得到的是路径名。如:
str1="e:\test\book1.xls"
str2="e:\test"