[snip code]
Various API calls are actually a more reliable choice. (Users can change
the location of "My Documents", so you cannot really trust %UserProfile%.) I
use SHGetSpecialFolderPath (Microsoft claims it is 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 & _
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 is located
at/In alternativa, si può solo scavare il percorso fuori dal Registro di
sistema. Si trova a HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer
\Shell Folders\Personal.
--
Seems every path leads me to nowhere.