Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA - Refer to cell for saves as file path

Status
Not open for further replies.

Randy11

Technical User
Oct 4, 2002
175
CA
Code below is used to generate a PDF file from a workbook. Would like to be able to alter the code so the save file path can be in cell A12 on Sheet("Setup"). This is current hard coded into the code as Filename:="C:\Temp_Test\" ....
Ideas appreciated

Sub Export_PDF_File()
'
' Export_PDF_File Macro
'

Dim dtDelay As Date
Call Calc_Auto
dtDelay = Now

Dim D
D = Format(Range("laDate").Value, "mmm-dd-yyyy")

ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Temp_Test\" & Sheets("SetUp").Range("A14").Value & D & ".pdf" _
, Quality:=xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, From:=1, To:=28, OpenAfterPublish:=False

If Now < (dtDelay + TimeSerial(0, 0, 5)) Then
Application.Wait dtDelay + TimeSerial(0, 0, 5)
End If

End Sub
 
hi,
Code:
dim sPath as string

sPath = Sheets("YourSheetName").Cells(WhatRow, WhatCol).Value


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Like this ?
Filename:=Sheets("SetUp").Range("A12").Value & Sheets("SetUp").Range("A14").Value & D & ".pdf"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

Code:
Filename = Sheets("SetUp").Range("A12").Value & Sheets("SetUp").Range("A14").Value & D & ".pdf"
Are you getting the right stuff in Filename?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Have tried all 3 methods suggested, no success.

Starts Publishing & runs into Run Time Error 1004 Document not saved....

Ideas?
 
WHAT do you see in Filename???

Do a Debug.Print!!!

Is it what you expect?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
SPath method worked well. Missed an error made when altering code. Thanks Skip, much appreciated. PH also thanks for your input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top