Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Windows cannot access the specified device, path or file. You may | Excel Discussion (Misc queries) | |||
ThisWorkbook.Path & Windows Vista | Excel Programming | |||
Windows API to Determine if File is Local/Convert Path to Drive Letter | Excel Programming | |||
hyperlink navigation path path wrong in Excel 2003 | Excel Discussion (Misc queries) | |||
Windows XP default path for temp file | Excel Programming |