dynamic creation of filename

A

Anne

Hello!
I want to save a project file with actual date and
time. "Pfad1" and "dateiname" contain the right values if
I use a messagebox, but fileSaveAs does not work. Only if
I use the absolute path saving is done. Is it impossible
to use dynamic filenames?
Anne

Dim Pfad1 As String
Pfad1 = CurDir
Dim dateiname As String
dateiname = projectnumber & ".Time Schedule." & Now
& ".mpp"
Application.FileSaveAs (Pfad1 & dateiname)

'this variant works
Application.FileSaveAs "G:\dummy\PM\AF Projekte\03444.Time
Schedule.20030725.mpp"
 
A

anne

Hi Jan,

I added a "\" as:
Dim ScheduleFileName As String
ScheduleFileName = Pfad1 & "\" & dateiname
Application.FileSaveAs ScheduleFileName

Unfortunately it is not the solution :-(
Anne
 
J

Jan De Messemaeker

Hi,

What EXACTLY is in Schedulefilename?
It definitely is not a valid address

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
Project Management Consultancy
Prom+ade BVBA
32-495-300 620
 
A

Anne

Hi Jan,

I shortened the program code as followed:

Dim projectnumber As String
projectname = ActiveProject.Name
projectnumber = Left(projectname, 6)
Dim dateiname As String

dateiname = CurDir & "\" & projectnumber & ".Time
Schedule." & Now & ".mpp"
Application.FileSaveAs dateiname

An error message occurs: "the file cannot be opened", but
I tried to save!
Anne
 
R

Rob Schneider

Find out (using debugging capability) the value of the text in the
variable "dateiname" to see that it is a valid file name. If not, then
revise your code which builds up this name.
 
J

Jan De Messemaeker

This is what I'm trying to tell since 5 or so postings.
Please debug the name.
HTH

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
Project Management Consultancy
Prom+ade BVBA
32-495-300 620
 
A

Anne

Hi,
the following code works, the problem arose from somewhere
else:
dateiname = CurDir & "\" & projectnumber & ".Time
Schedule." & Now & ".mpp"
Application.FileSaveAs dateiname

Anne
 

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