|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 dljyh2009 于 2023-3-8 17:13 编辑
Sub 提取附件()
'
' 宏3 宏
'
Dim i As Byte, arr
Dim Brr(0 To 5)
Dim ss As String
Dim spath As String '总路径的设置
spath = Range("q1").Value '其默认值为内网中:\\Dlyhzj2020\工程造价咨询管理信息系统3.0\2.合同管理\2.1工程造价咨询合同
Dim WJJ As String '得到文件夹的名称
WJJ = Replace(Cells(ActiveCell.Row, 2).Value, "-", "") & Cells(ActiveCell.Row, 3).Value
arr = Array("合同签署版PDF", "合同补充协议", "合同Word版", "合同其它附件", "合同投标简版(压缩)", "中标通知书")
For i = 0 To 5 '定位列号
ii = Range("2:2").End(xlToRight).Column + 1
Set findcell = Range("2:2").Find("*" & arr(i) & "*", LookAt:=xlPart) '如果 是完全匹配 XLPART 改成XLWHOLE
If Not findcell Is Nothing Then col = findcell.Column Else Cells(2, ii).Value = arr(i): col = ii
Brr(i) = Split(Columns(col).Address(0, 0), ":")(0)
Next
ss = spath & "\" & WJJ & "\合同签署版PDF"
ss1 = ThisWorkbook.Path
Set fso = CreateObject("scripting.filesystemobject")
' Set ff = fso.getfolder(spath & "\" & WJJ & "\合同签署版PDF") 'ThisWorkbook.Path是当前代码文件所在路径,路径名可以根据需求修改
Set ff = fso.getfolder(ss) '
For Each f In ff.Files
MsgBox f.Name
Next f
Range("Y13").Select
Selection.ClearContents
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
spath & "\" & WJJ & "\20220824大连椒金山城市更新建设有限公司办公室装修工程结算审核.docx" _
, TextToDisplay:= _
"有"
Range("Z12").Select
End Sub
问题:SS与SS1,显示的路径是一样的,但 Set ff = fso.getfolder(ss)就不能通过,“提示路径未找到” Set ff = fso.getfolder(ss1)就可以通过,问题出来哪,
|
|