Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default get the current filename as a variable

The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default get the current filename as a variable

ActiveWorkbook.Name will give you the file name.
ActiveWorkbook.FullName will give you the file name and the full path.

ActiveWorkbook.Filename is not available.




"Janis" schreef in bericht
...
The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default get the current filename as a variable

myFileName = ActiveWorkbook.Fullname

if you want the path

myFileName = ActiveWorkbook.Name

without

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default get the current filename as a variable


Same here.

;-)

"Bob Phillips" schreef in bericht
...
myFileName = ActiveWorkbook.Fullname

if you want the path

myFileName = ActiveWorkbook.Name

without

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save
the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default get the current filename as a variable

Janis,

there is no .filename property - you want to use the .fullname (to get the
path, if one exists, ie. it's not a new workbook) or .name (just the name)

HTH,
Mike

"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default get the current filename as a variable

Try this: I added a : after Documents in your Const. I am not familiar with
MAC file naming, but I thought there should be a separator for the
folder/file. In any case, myFileName should get the desired results there.
You just need to make sure that fName puts the path and file name together
correctly for MAC.

Sub SaveMe()
Dim fName As String
Dim myFileName As String
Const fPath As String = "Mac OS X:Users:jrough:Documents:"

myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & " " &
Date & ".xls"
fName = fPath & myFileName
ActiveWorkbook.SaveAs Filename:=fName

End Sub

Mike F
"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default get the current filename as a variable

Sorry, word wrap cut my long line

Sub SaveMe()
Dim fName As String
Dim myFileName As String
Const fPath As String = "Mac OS X:Users:jrough:Documents:"

myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) _
& " " & Date & ".xls"
fName = fPath & myFileName
ActiveWorkbook.SaveAs Filename:=fName

End Sub

Mike F
"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default get the current filename as a variable

even the timestamp <g

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"moon" <6369706865725F6475646540706C616E65742E6E6C wrote in message
. ..

Same here.

;-)

"Bob Phillips" schreef in bericht
...
myFileName = ActiveWorkbook.Fullname

if you want the path

myFileName = ActiveWorkbook.Name

without

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save
the
current filename with the date appended. I am trying to put the

current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub








  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default get the current filename as a variable

I think you are right about the separator for the documents file. Thanks,

"Mike Fogleman" wrote:

Try this: I added a : after Documents in your Const. I am not familiar with
MAC file naming, but I thought there should be a separator for the
folder/file. In any case, myFileName should get the desired results there.
You just need to make sure that fName puts the path and file name together
correctly for MAC.

Sub SaveMe()
Dim fName As String
Dim myFileName As String
Const fPath As String = "Mac OS X:Users:jrough:Documents:"

myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & " " &
Date & ".xls"
fName = fPath & myFileName
ActiveWorkbook.SaveAs Filename:=fName

End Sub

Mike F
"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub





  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default get the current filename as a variable

It is really tricky. The .xls extension saves twice and I can't get it to
print the time and the date but it now compiles. Thanks,

"Mike Fogleman" wrote:

Sorry, word wrap cut my long line

Sub SaveMe()
Dim fName As String
Dim myFileName As String
Const fPath As String = "Mac OS X:Users:jrough:Documents:"

myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) _
& " " & Date & ".xls"
fName = fPath & myFileName
ActiveWorkbook.SaveAs Filename:=fName

End Sub

Mike F
"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save the
current filename with the date appended. I am trying to put the current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default get the current filename as a variable

Janis, I consulted with a MAC user and determined the following code will do
as you asked. It adds the time and removes the double.xls at the end. MAC
doesn't care about the /'s in the date, as Windows does, so I left those
alone. The colons in TIME had to go with either OS, so it is re-formatted
with dot separators. Finally MAC appends the file extension for you, so I
removed it from the code and let MAC do it's thing when the file is saved.

Sub SaveMe()
Dim fName As String
Dim myFileName As String
Const fPath As String = "Mac OS X:Users:jrough:Documents:"

myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) _
& " " & Date & " " & Format(Time, "hh.mm.ss")
fName = fPath & myFileName
ActiveWorkbook.SaveAs Filename:=fName
End Sub

Mike F
"Janis" wrote in message
...
It is really tricky. The .xls extension saves twice and I can't get it to
print the time and the date but it now compiles. Thanks,

"Mike Fogleman" wrote:

Sorry, word wrap cut my long line

Sub SaveMe()
Dim fName As String
Dim myFileName As String
Const fPath As String = "Mac OS X:Users:jrough:Documents:"

myFileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) _
& " " & Date & ".xls"
fName = fPath & myFileName
ActiveWorkbook.SaveAs Filename:=fName

End Sub

Mike F
"Janis" wrote in message
...
The myFileName line does not compile. What I want to do here is save
the
current filename with the date appended. I am trying to put the
current
filename into the Sub
tnx,
saveIndesign()
'Appends date to filename so as to not write over an existing file

Const fPath As String = "Mac OS X:Users:jrough:Documents"
Dim fName As String
Dim myFileName As String
myFileName = ActiveWorkbook.Filename
fName = fPath & myFileName & Time()
ActiveWorkbook.SaveAs Filename:=fName
End Sub







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I display the current XLS filename in a toolbar? [email protected] Excel Discussion (Misc queries) 1 June 4th 10 12:59 PM
Converting a Variable Filename to a Constant Filename Magnivy Excel Programming 2 August 15th 06 06:13 PM
Filename with current Date() Chip Pearson Excel Programming 1 January 8th 04 07:18 AM
Filename with current Date() Graham[_5_] Excel Programming 1 January 8th 04 07:15 AM
Append current date to filename Rhonda[_2_] Excel Programming 5 September 16th 03 11:34 AM


All times are GMT +1. The time now is 10:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"