path of workbook

F

fabalicious

With

ActiveWorkbook.FullName

i can get the full path of my active workbook. Using .Name instead onl
the file name. how can i get ONLY the path without the filename?

is there a predefined function for it? if not, has anyone any idea ho
to chop of the last bit ("/filename.xls")?

Come on, big props to the one sweetening my weekend by giving me th
illusion of having solved everything i need for my macro...
(it's 15:30 here already ;-))

Fabaliciou
 
F

Fraggs

if you use the web toolbar you can navigate to where you want to go
navigate to a file in the folder you want to open then before you clic
ok to go to it, get rid of the file name and you have a neat link to
folder. Then just copy it into your macro or do whateva you see fit t
it
 
D

Don Guillett

try
activeworkbook.path

Here is a backup file I use to backup to the current directory.

Sub Backup() 'kept in personal.xls & assigned to toolbar button
On Error GoTo BackupFile
MkDir CurDir & "\Backup"
BackupFile:
With ActiveWorkbook
MyWB = .Path & "\BACKUP\" & .Name
.SaveCopyAs MyWB
.Save
End With
End Sub
 
F

fabalicious

.Path

as simple as that! Suspected that but didn't work when I tried it out
There must have been another mistake...

Cheers

F
 
J

JMay

Don:
Thanks for the code. It works great.
Question however..
Users tend to forget to Run the macro before closing,
so quickly I thought of adding your Sub Backup() in the
Workbook BeforeClose as a one-liner, which works fine:

Only thing though is when you open the Backed-up file in the Backup folder
and then close it the code runs creating an error, since it is trying again
to backup the backup. I'm at the place of a dog chasing his tail on this.
Could you assist me?? I'm getting dizzy..
Thanks in advance.
JMay


Don Guillett said:
try
activeworkbook.path

Here is a backup file I use to backup to the current directory.

Sub Backup() 'kept in personal.xls & assigned to toolbar button
On Error GoTo BackupFile
MkDir CurDir & "\Backup"
BackupFile:
With ActiveWorkbook
MyWB = .Path & "\BACKUP\" & .Name
.SaveCopyAs MyWB
.Save
End With
End Sub
 
D

Don Guillett

Haven't thought about it but try

on error exit sub


--
Don Guillett
SalesAid Software
[email protected]
JMay said:
Don:
Thanks for the code. It works great.
Question however..
Users tend to forget to Run the macro before closing,
so quickly I thought of adding your Sub Backup() in the
Workbook BeforeClose as a one-liner, which works fine:

Only thing though is when you open the Backed-up file in the Backup folder
and then close it the code runs creating an error, since it is trying again
to backup the backup. I'm at the place of a dog chasing his tail on this.
Could you assist me?? I'm getting dizzy..
Thanks in advance.
JMay
 
Top