ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to save the complete path of the file we open? (https://www.excelbanter.com/excel-programming/380514-re-how-save-complete-path-file-we-open.html)

Gary Keramidas

how to save the complete path of the file we open?
 
one way

fPath = Application.ActiveWorkbook.Path

--


Gary


"GeneWan" wrote in message
...
eg. my code prompted user to choose the file(s) to be opened within the same
path. How can I save the path so that I could use it later on?

purpose is so that I can create a file in the same path afterwards..





GeneWan

how to save the complete path of the file we open?
 
this won't work as the file intended to open is for reading and not opened
onto an excel worksheet...

thanks regardless :)


"Gary Keramidas" wrote:

one way

fPath = Application.ActiveWorkbook.Path

--


Gary


"GeneWan" wrote in message
...
eg. my code prompted user to choose the file(s) to be opened within the same
path. How can I save the path so that I could use it later on?

purpose is so that I can create a file in the same path afterwards..






Nick_F

how to save the complete path of the file we open?
 
Not sure if by your last comment you solved the problem but if you are
trying to save something other than a .XLS file you can use file
filters or if the file is read only and you cannot save over it try
changing the attributes...

Get Path adapted from Nick #1's code :

Sub Getpath()

Dim FilePath As String
Dim FileName As String
Dim Filter As String

' Insert whatever extension you want here e.g. *.txt
Filter = "Excel Files (*.xls), *.xls"

FileName = Application.GetOpenFilename(Filter)
FilePath=Left(FileName, InStrRev(FileName, "\"))

End Sub

If the Read Only file attribute is your problem insert this just before
overwriting (saving):

' Acts like unchecking Hidden, Read Only and Archive tick boxes in the
'right click
' properties window of a file
SetAttr (FilePath), vbNormal

Best of luck
Nick Flyger


Nick_F

how to save the complete path of the file we open?
 
should read...

SetAttr (Filename), vbNormal



All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com