我有以下代码:
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
中发布该位置,我将如何编码?
最佳答案
I want to be able to post that location in cell J2, how will I code that?
其实很简单
换行
FileName:=SAVE_PATH & "\" & cell.Value & ".pdf"
和
FileName:=Thisworkbook.Sheets("Sheet1").Range("J2").Value & _
"\" & cell.Value & ".pdf"
更改
Thisworkbook
和 Sheet1
到相关的工作簿或工作表。
关于vba - 从单元格中选择保存路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30516435/