LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Path windows in VBA Excel

Auric__ ha usato la sua tastiera per scrivere :


Various API calls are actually a more reliable choice. (Users can change
the location of "My Documents", so you can't really trust %UserProfile%.) I
use SHGetSpecialFolderPath (Microsoft claims it's only supported for
Windows 2000, but it works for me under XP).

Google traduzione:
Diverse le chiamate API sono in realtà una scelta più affidabile. (Gli
utenti possono modificare la posizione di "Documenti", così non si può
davvero fidare %UserProfile%). Io uso SHGetSpecialFolderPath (Microsoft
afferma che è supportato solo per Windows 2000, ma funziona per me sotto
XP).

Try this/Prova questo:

Private Declare Function SHGetSpecialFolderPath Lib "shell32" _
Alias "SHGetSpecialFolderPathA" ( _
ByVal hwndOwner As Long, _
ByVal lpszPath As String, _
ByVal nFolder As Long, _
ByVal fCreate As Long) As Long

Private Const MAX_PATH = 260
Private Const CSIDL_PERSONAL = 5

Sub Salva()
Dim Forli As String
Dim Sav As String
Dim tmp1 As Long, tmp2 As Long
Dim returnedPath As String

Forli = Range("F2").Value
Sav = Range("H2").Value

returnedPath = Space$(MAX_PATH + 1)
tmp1 = SHGetSpecialFolderPath(0, returnedPath, 5&, 0)
tmp2 = InStr(returnedPath, Chr$(0))
'Handle the terminating null, if present.
'Maneggiare il nullo di terminazione, se presente.
If tmp2 Then returnedPath = Left$(returnedPath, tmp2 - 1)
ActiveWorkbook.SaveAs Filename:=returnedPath & "\Schede\" & Forli & _
"_" & Sav & ".xls", _
FileFormat:=xlNormal
ActiveWindow.Close
End Sub

(Note that the folder "Schede" must already exist, or this will fail./Si
noti che il "Schede" cartella deve già esistere, o questo avrà esito
negativo.)

Alternately, you can just dig the path out of the registry. It's located
at/In alternativa, si può solo scavare il percorso fuori dal Registro di
sistema. Si trova a HKCU\Software\Microsoft\Windows\CurrentVersion\Exp lorer
\Shell Folders\Personal.


Hi,

thanks a lot for your solution.

I will try it next days.

In the pc where I use my solution are pc where the windows is
configured normally and the personalize is blocked for normail user, so
I can trust %userprofile%

--
M@rco.


 
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
Windows cannot access the specified device, path or file. You may Stacey123 Excel Discussion (Misc queries) 1 April 1st 08 08:41 PM
ThisWorkbook.Path & Windows Vista Tom Excel Programming 1 November 29th 07 01:06 PM
Windows API to Determine if File is Local/Convert Path to Drive Letter Johnny[_10_] Excel Programming 0 March 10th 06 01:20 PM
hyperlink navigation path path wrong in Excel 2003 CE Admin Excel Discussion (Misc queries) 5 January 7th 06 07:47 PM
Windows XP default path for temp file FCWL Excel Programming 0 September 25th 04 03:45 AM


All times are GMT +1. The time now is 02:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"