macros

D

Dawn

I am trying to write a macro prevent users from saving
files with the wrong file name and in the wrong location.
I have the path done, however, I need to pull the file
name from a cell within the workbook.
 
D

Dave Peterson

Dim myPath As String
myPath = "C:\my documents\excel\test"

ActiveWorkbook.SaveAs _
Filename:=myPath & "\" & Worksheets("Sheet1").Range("a1").Value


Be careful. If there's a date in A1, you'll want to format it to make it a
valid filename:

ActiveWorkbook.SaveAs _
Filename:=myPath & "\" & _
Format(Worksheets("sheet1").Range("a1"), "yyyymmdd")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top