我有以下代码:
Const SAVE_PATH = "S:\Divisional Support\RVU Programs\Payroll 2015\2015-04 April\PDF's\Baptist Easley"
'paste file destination in the above location'
Dim cell As Range
Dim wsSummary As Worksheet
Dim counter As Long
Set wsSummary = Sheets("PERFORM. SUM. - EASLEY")
For Each cell In Worksheets("NAME KEY").Range("$H:$H")
If cell.Value <> "" Then
'progress in status bar
counter = counter + 1
Application.StatusBar = "Processing file: " & counter & "/1042"
With wsSummary
.Range("$A$4").Value = cell.Value
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=SAVE_PATH & "\" & cell.Value & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
End If
Next cell
Set wsSummary = Nothing
End Sub
我的问题很简单,而不必进入代码来更改保存位置:Const SAVE_PATH = "S:\Divisional Support\RVU Programs\Payroll 2015\2015-04 April\PDF's\Baptist Easley"
我希望能够在单元格J2
中发布该位置,我将如何编码?
答案 0 :(得分:4)
我希望能够在单元格J2中发布该位置,我将如何编写该代码?
实际上非常简单
替换
行FileName:=SAVE_PATH & "\" & cell.Value & ".pdf"
与
FileName:=Thisworkbook.Sheets("Sheet1").Range("J2").Value & _
"\" & cell.Value & ".pdf"
将Thisworkbook
和Sheet1
更改为相关的工作簿或工作表。