Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Saving files one level up

Hi,

I use the following lines to save data to a file:
ActiveWorkbook.SaveAs FileName:=NewFileName, _
FileFormat:=xlText, _
CreateBackup:=False

It stores the file in the same directory as the input file that I have
pointed out with the lines:
WholeFileName = Application.GetOpenFilename _
(FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title)

My question is how I can store the file one level up, in the directory above?
Can I type in the file name with path and everything as NewFileName?

Best regards,
/Sören
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving files one level up

Dim myPath as string
dim wkbk as workbook
dim WholeFileName as variant
'...
WholeFileName = Application.GetOpenFilename _
(FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title)

if wholefilename = false then
exit sub
end if

set wkbk = workbooks.open(filename:=wholefilename)

mypath = wkbk.path
newfilename = mypath & "\..\" & "whateverstring.txt"

=======
If you remember your old DOS commands, this is equivalent to:

cd ..
to go up one level.

(You may want to add a check to make sure you weren't in the root folder of the
drive--so you couldn't go up a level.)


Sören_Marodören wrote:

Hi,

I use the following lines to save data to a file:
ActiveWorkbook.SaveAs FileName:=NewFileName, _
FileFormat:=xlText, _
CreateBackup:=False

It stores the file in the same directory as the input file that I have
pointed out with the lines:
WholeFileName = Application.GetOpenFilename _
(FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title)

My question is how I can store the file one level up, in the directory above?
Can I type in the file name with path and everything as NewFileName?

Best regards,
/Sören


--

Dave Peterson
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
How can I save Excel subtotals without saving hidden (Level 3) r Judy Stumpf Excel Worksheet Functions 0 February 13th 07 03:55 PM
Closing files and saving files dan Excel Worksheet Functions 0 August 15th 06 04:07 AM
Using macro to convert single level BOM to Multi Level BOM andrew_chong Excel Programming 0 February 7th 06 08:57 PM
moving .xla files and top level tech information blakieto Excel Programming 1 June 17th 04 04:02 AM
Why, when I create workbook-level name does it jump it to Sheet-level ? Charles Jordan Excel Programming 1 November 5th 03 08:43 PM


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