![]() |
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 |
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 |
All times are GMT +1. The time now is 12:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com