Вопрос

I have a small program that creates a load of files and saves to a folder specified by the user. Currently the top of the userform looks like the following when initialised:

enter image description here

I'd prefer if when the userform opens and also when the dialog for choosing a appears (via the Destination button) that a general default is already shown:

enter image description here

Can the program find the pathway to a user's desktop?

Это было полезно?

Решение

To get the path to the users desktop, use:

PathToDesktop = Environ("USERPROFILE") & "\Desktop"

Другие советы

If you are doing this in excel-vba, the following code would save the current workbook as a copy to the user's desktop... you can probably figure out what you're doing from there.

Dim DesktopPath As String 
DesktopPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator 
ActiveWorkbook.SaveAs DesktopPath & "filename.xls"
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top