请各位老师帮忙把下面这段VB代码里面引用的绝对文件路径改成相对路径
PrivateSubForm_Load()DimwbaAsWorkbook,wbbAsWorkbookDimErowAsLong'--------------------...
Private Sub Form_Load()
Dim wba As Workbook, wbb As Workbook
Dim Erow As Long
'------------------------以下代码检测1.xlsx是否打开------------------------------
For Each wba In Workbooks
If wba.name = "F:\Database\柜体.xlsb" Then Exit For
Next
If wba Is Nothing Then
Set wba = Workbooks.Open("F:\Database\柜体.xlsb", False) '如果该文件没打开,则打开之
End If
'------------------------以下代码进行复制处理工作--------------------------------
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wbb = Workbooks.Open("F:\Database\柜体2.xlsb", , False)
Erow = Application.Max(wbb.Worksheets(2).[a1048576].End(3).row, 5)
wba.Worksheets(1).Range("A1:G5").Copy wbb.Worksheets(2).Cells(Erow + 1, "A")
wba.Worksheets(1).Range("A1:G5") = ""
wba.Save
wba.Close
wbb.Save
wbb.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
有愿意帮忙的老师请贴出修改后的代码,VB代码。小女子不胜感激!!!
If wba.name = "F:\Database\柜体.xlsb" Then Exit For
Set wba = Workbooks.Open("F:\Database\柜体.xlsb", False)
Set wbb = Workbooks.Open("F:\Database\柜体2.xlsb", , False)
就这三个地方的路径改为相对路径 展开
Dim wba As Workbook, wbb As Workbook
Dim Erow As Long
'------------------------以下代码检测1.xlsx是否打开------------------------------
For Each wba In Workbooks
If wba.name = "F:\Database\柜体.xlsb" Then Exit For
Next
If wba Is Nothing Then
Set wba = Workbooks.Open("F:\Database\柜体.xlsb", False) '如果该文件没打开,则打开之
End If
'------------------------以下代码进行复制处理工作--------------------------------
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wbb = Workbooks.Open("F:\Database\柜体2.xlsb", , False)
Erow = Application.Max(wbb.Worksheets(2).[a1048576].End(3).row, 5)
wba.Worksheets(1).Range("A1:G5").Copy wbb.Worksheets(2).Cells(Erow + 1, "A")
wba.Worksheets(1).Range("A1:G5") = ""
wba.Save
wba.Close
wbb.Save
wbb.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
有愿意帮忙的老师请贴出修改后的代码,VB代码。小女子不胜感激!!!
If wba.name = "F:\Database\柜体.xlsb" Then Exit For
Set wba = Workbooks.Open("F:\Database\柜体.xlsb", False)
Set wbb = Workbooks.Open("F:\Database\柜体2.xlsb", , False)
就这三个地方的路径改为相对路径 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询