Macro Path

R

Rocky Lam

I have a macro save file to c: drive

How do I change to save files to G:\Purchase Order\2004\

Thanks

The NEWORDER macro

Sub NEWORDER()
'
' NEWORDER Macro

'

'Specify the named ranged ORD as the ORDER# and DIRECT, DT, and ORD to
create the variable PTH as the path.
Dim ORDER#, PTH
ORDER# = Range("ORD").Value
PTH = Range("DIRECT").Value & Range("DT").Value & " - " &
(Range("ORD").Value + 1)

'Increase the order number as by 1 and save the workbook capturing the new
order number.
Range("ORD") = ORDER# + 1
ActiveWorkbook.Save

'Save the file as a new order according to the path above.
ActiveWorkbook.SaveAs Filename:=PTH



End Sub
 
D

Dave Peterson

You could define a variable to hold that string and define another to hold the
filename (but I'm not quite sure how that was built):

dim myPath as string
dim myFileName as string
......
mypath = "G:\Purchase Order\2004\"
myFileName = Range("ORD").Value + 1
....
ActiveWorkbook.SaveAs Filename:=myPath & myFilename

===
ActiveWorkbook.SaveAs Filename:= "G:\Purchase Order\2004\" & myFilename

would have worked, too. But if you use it more than once, you'll have to
remember to change it in multiple spots when 2005 rolls around.
 
Top