Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Saving to a specific location

Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original was
opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Saving to a specific location

Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" & inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message ...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original was
opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Saving to a specific location

Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder that as
yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to create
this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original was
opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Saving to a specific location

You can create the folder with code first if it not exist

Sub testing()
Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA\" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"
End Sub


Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message ...
Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder that as
yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to create
this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original was
opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Saving to a specific location

Hi Ron
Having a bit of bother piecing it all together - i have this at the moment,
but it returns a "Run-time error '76': Path not found" when it reaches
'MkDir DirName'- any thoughts?

Sub New_Name()

Open_All_Sheets

Application.ScreenUpdating = False

Application.EnableEvents = False

Dim inputText As String

inputText = Application.InputBox("Enter name here", _
"Person's Name", , , , , 2)

Sheets("Data Input").Range("D1:H1").Value = inputText


Application.Run "Lock_All_Sheets"

Application.EnableEvents = True

Application.ScreenUpdating = True


Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA-" & inputText & ""
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PGA\Personal
Golf Analyser-" & inputText & "\Personal Golf Analyser-" & inputText &
".xls"

ThisWorkbook.Close SaveChanges:=False

End Sub



Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function

Sandy

"Ron de Bruin" wrote in message
...
You can create the folder with code first if it not exist

Sub testing()
Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA\" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"
End Sub


Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder that
as yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to
create this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original
was opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Saving to a specific location

Sorry - wrong code should read as follows - but still produces same error at
MkDir after running thro the function

Sub New_Name()

Open_All_Sheets

Application.ScreenUpdating = False

Application.EnableEvents = False

Dim inputText As String

inputText = Application.InputBox("Enter name here", _
"Golfer's Name", , , , , 2)

Sheets("Data Input").Range("D1:H1").Value = inputText

Application.Run "Lock_All_Sheets"

Application.EnableEvents = True

Application.ScreenUpdating = True


Dim Dirname As String
Dirname = "D\Sandy's Documents\All PGA\ Personal Golf Analyser\Personal
Golf Analyser-" & inputText & ""
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PGA\Personal
Golf Analyser-" & inputText & "\Personal Golf Analyser-" & inputText &
".xls"

'ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"

ThisWorkbook.Close SaveChanges:=False

End Sub

Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function

Sandy

"Ron de Bruin" wrote in message
...
You can create the folder with code first if it not exist

Sub testing()
Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA\" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"
End Sub


Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder that
as yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to
create this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original
was opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Saving to a specific location

Use this

Do you want inputtext as folder and also be a part of the file name ?
Is that correct



inputText = Application.InputBox("Enter name here", _
"Person's Name", , , , , 2)

Dirname = "D\Sandy's Documents\All PSA\PSA-" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
' dirname is the path so you only add the file name here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\Personal Golf Analyser-" & inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message ...
Hi Ron
Having a bit of bother piecing it all together - i have this at the moment,
but it returns a "Run-time error '76': Path not found" when it reaches
'MkDir DirName'- any thoughts?

Sub New_Name()

Open_All_Sheets

Application.ScreenUpdating = False

Application.EnableEvents = False

Dim inputText As String

inputText = Application.InputBox("Enter name here", _
"Person's Name", , , , , 2)

Sheets("Data Input").Range("D1:H1").Value = inputText


Application.Run "Lock_All_Sheets"

Application.EnableEvents = True

Application.ScreenUpdating = True


Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA-" & inputText & ""
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PGA\Personal
Golf Analyser-" & inputText & "\Personal Golf Analyser-" & inputText &
".xls"

ThisWorkbook.Close SaveChanges:=False

End Sub



Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function

Sandy

"Ron de Bruin" wrote in message
...
You can create the folder with code first if it not exist

Sub testing()
Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA\" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"
End Sub


Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder that
as yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to
create this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original
was opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving to a specific location

Watch your typing:

You need a colon after the drive letter and is there supposed to be a space
before the " Personal Golf Analyser" portion of the path.


Dirname = "D:\Sandy's Documents\All PGA\ Personal Golf Analyser\" _
& "Personal Golf Analyser-" & inputText

And if you use mkdir to make a folder, then each parent folder has to exist
before you can make the sub folder.

'assuming that there is a D: drive
on error resume next
mkdir "D:\Sandy's Documents"
mkdir "D:\Sandy's Documents\all pga"
mkdir "D:\Sandy's Documents\all pga\Personal golf analyser"
'... and so forth
On error resume next


This also assumes that there aren't any other errors that could happen (files
with the same name causing the mkdir to fail, permission restrictions, space
problems....)

Sandy wrote:

Sorry - wrong code should read as follows - but still produces same error at
MkDir after running thro the function

Sub New_Name()

Open_All_Sheets

Application.ScreenUpdating = False

Application.EnableEvents = False

Dim inputText As String

inputText = Application.InputBox("Enter name here", _
"Golfer's Name", , , , , 2)

Sheets("Data Input").Range("D1:H1").Value = inputText

Application.Run "Lock_All_Sheets"

Application.EnableEvents = True

Application.ScreenUpdating = True

Dim Dirname As String
Dirname = "D\Sandy's Documents\All PGA\ Personal Golf Analyser\Personal
Golf Analyser-" & inputText & ""
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PGA\Personal
Golf Analyser-" & inputText & "\Personal Golf Analyser-" & inputText &
".xls"

'ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"

ThisWorkbook.Close SaveChanges:=False

End Sub

Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function

Sandy

"Ron de Bruin" wrote in message
...
You can create the folder with code first if it not exist

Sub testing()
Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA\" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"
End Sub


Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder that
as yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to
create this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original
was opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Saving to a specific location

Yes Ron folder and filename.
Works perfectly now thanks for your expertise and patience.
Sandy

"Ron de Bruin" wrote in message
...
Use this

Do you want inputtext as folder and also be a part of the file name ?
Is that correct



inputText = Application.InputBox("Enter name here", _
"Person's Name", , , , , 2)

Dirname = "D\Sandy's Documents\All PSA\PSA-" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
' dirname is the path so you only add the file name here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\Personal Golf Analyser-"
& inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi Ron
Having a bit of bother piecing it all together - i have this at the
moment, but it returns a "Run-time error '76': Path not found" when it
reaches 'MkDir DirName'- any thoughts?

Sub New_Name()

Open_All_Sheets

Application.ScreenUpdating = False

Application.EnableEvents = False

Dim inputText As String

inputText = Application.InputBox("Enter name here", _
"Person's Name", , , , , 2)

Sheets("Data Input").Range("D1:H1").Value = inputText


Application.Run "Lock_All_Sheets"

Application.EnableEvents = True

Application.ScreenUpdating = True


Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA-" & inputText & ""
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All
PGA\Personal Golf Analyser-" & inputText & "\Personal Golf Analyser-" &
inputText & ".xls"

ThisWorkbook.Close SaveChanges:=False

End Sub



Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function

Sandy

"Ron de Bruin" wrote in message
...
You can create the folder with code first if it not exist

Sub testing()
Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA\" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"
End Sub


Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder
that as yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to
create this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original
was opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Saving to a specific location

Hi Sandy

Like Dave already posted the parent folder must exist
Also you can test if there is something in inputText and test if there are no wrong characters
to avoid errors.


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message ...
Yes Ron folder and filename.
Works perfectly now thanks for your expertise and patience.
Sandy

"Ron de Bruin" wrote in message
...
Use this

Do you want inputtext as folder and also be a part of the file name ?
Is that correct



inputText = Application.InputBox("Enter name here", _
"Person's Name", , , , , 2)

Dirname = "D\Sandy's Documents\All PSA\PSA-" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
' dirname is the path so you only add the file name here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\Personal Golf Analyser-"
& inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi Ron
Having a bit of bother piecing it all together - i have this at the
moment, but it returns a "Run-time error '76': Path not found" when it
reaches 'MkDir DirName'- any thoughts?

Sub New_Name()

Open_All_Sheets

Application.ScreenUpdating = False

Application.EnableEvents = False

Dim inputText As String

inputText = Application.InputBox("Enter name here", _
"Person's Name", , , , , 2)

Sheets("Data Input").Range("D1:H1").Value = inputText


Application.Run "Lock_All_Sheets"

Application.EnableEvents = True

Application.ScreenUpdating = True


Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA-" & inputText & ""
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All
PGA\Personal Golf Analyser-" & inputText & "\Personal Golf Analyser-" &
inputText & ".xls"

ThisWorkbook.Close SaveChanges:=False

End Sub



Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function

Sandy

"Ron de Bruin" wrote in message
...
You can create the folder with code first if it not exist

Sub testing()
Dim Dirname As String
Dirname = "D\Sandy's Documents\All PSA\PSA\" & inputText
If Not DirectoryExist(Dirname) Then
MkDir Dirname
End If
'your save line here
ThisWorkbook.SaveCopyAs Filename:=Dirname & "\testfile.xls"
End Sub


Function DirectoryExist(sstr As String)
'Tom Oglivy
Dim lngAttr As Long
DirectoryExist = False
If Dir(sstr, vbDirectory) < "" Then
lngAttr = GetAttr(sstr)
If lngAttr And vbDirectory Then _
DirectoryExist = True
End If
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Thanks Ron

I've just had another thought - is it possible to SaveAs to a folder
that as yet doesn't exist. Eg

"D\Sandy's Documents\All PSA\PSA\(--and then use the "inputText" to
create this folder--)"

Sandy

"Ron de Bruin" wrote in message
...
Hi Sandy

ThisWorkbook.SaveCopyAs Filename:="D:Sandy's Documents\All PSA\PSA-" &
inputText & ".xls"


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sandy" wrote in message
...
Hi
I have a bit of code as part of a 'Sub'- namely:

ThisWorkbook.SaveCopyAs Filename:="PSA-" & inputText & ".xls"

which saves a copy of a workbook to the same folder that the original
was opened from, in this case -

'D:Sandy's Documents\All PSA'.

How can I adjust this to save the file in a specific location eg

'D:\Sandy's Documents\All PSA\PSA\Excel 95-2003'

Thanks
Sandy




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
prevent location change before saving NickHK Excel Programming 0 December 12th 06 02:55 AM
saving w/sheet to different location Nigel[_21_] Excel Programming 7 October 8th 05 12:17 PM
Saving Excel in more than one location Mark C via OfficeKB.com Excel Programming 3 August 16th 05 05:57 AM
VBA for saving a file to a specific location TimT Excel Programming 6 July 7th 05 08:50 PM
Saving in a location Greg Brow Excel Programming 2 February 4th 05 02:57 PM


All times are GMT +1. The time now is 08:04 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"