فرض کنید در یک Userform یک Textbox ویک Commandbotton داریم .میخواهیم با کلیک بر Commandbotton پنجره Browse باز شده و با یافتن پوشه مورد نظر و انتخاب آن، آدرس پوشه در TextBox درج شود.
ممنون میشم راهنمایی بفرمائید.
|
🖤 پیام تسلیتبا نهایت تأسف و تأثر، باخبر شدیم جناب آقای محمد محمدی با نام کاربری smartman ، از مدیران ارزشمند انجمن اکسل ایران، دار فانی را وداع گفتهاند. ایشان سالها با دانش، تجربه، اخلاق نیکو و روحیه کمک به دیگران، سهم بزرگی در رشد و پویایی انجمن داشتند و خاطره حضور ارزشمندشان همواره در ذهن اعضای انجمن باقی خواهد ماند. مدیریت و اعضای انجمن ExcelIran این ضایعه را به خانواده محترم ایشان، دوستان و تمامی اعضای انجمن تسلیت عرض نموده و از خداوند متعال برای آن مرحوم، رحمت و مغفرت الهی و برای بازماندگان صبر و شکیبایی مسئلت دارند.
انا لله و انا الیه راجعون
|
Private Sub CommandButton1_Click()
Dim AddFile As FileDialog
Set AddFile = Application.FileDialog(msoFileDialogFilePicker)
With AddFile
.Title="فایل مورد نظرتان را انتخاب کنید"
If .Show <> -1 Then GoTo NoSelection
TextBox1.Value = .SelectedItems(1)
End With
NoSelection:
End Sub
Private Sub CommandButton1_Click()
Dim AddFile As FileDialog
Set AddFile = Application.FileDialog(msoFileDialogFilePicker)
With AddFile
.Title="فایل مورد نظرتان را انتخاب کنید"
If .Show <> -1 Then GoTo NoSelection
TextBox1.Value = .SelectedItems(1)
End With
NoSelection:
End Sub
Private Sub CommandButton1_Click()
Dim AddFile As FileDialog
Set AddFile = Application.FileDialog(msoFileDialogFilePicker)
With AddFile
.Title = "ÝÇíá ãæÑÏ äÙÑÊÇä ÑÇ ÇäÊÎÇÈ ˜äíÏ"
If .Show <> -1 Then GoTo NoSelection
TextBox1 = .SelectedItems(1)
For i = 1 To Len(TextBox1)
If Mid(TextBox1, i, 1) = "\" Then
k = i
End If
Next
End With
TextBox1 = Left(TextBox1, k - 1)
NoSelection:
End Sub
Private Sub CommandButton1_Click()
Dim AddFile As FileDialog
Set AddFile = Application.FileDialog(msoFileDialogFilePicker)
With AddFile
.Title = "ÝÇíá ãæÑÏ äÙÑÊÇä ÑÇ ÇäÊÎÇÈ ˜äíÏ"
If .Show <> -1 Then GoTo NoSelection
xx = .SelectedItems(1)
For i = Len(xx) To 1 Step -1
If Mid(xx, i, 1) = "\" Then
k = i
Exit For
End If
Next
End With
TextBox1 = Left(xx, k - 1)
NoSelection:
End Sub
Private Sub CommandButton1_Click()
Dim diaFolder As FileDialog
Dim selected As Boolean
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
diaFolder.AllowMultiSelect = False
selected = diaFolder.Show
If selected Then
TextBox1.Value = diaFolder.SelectedItems(1)
End If
Set diaFolder = Nothing
End Sub
Private Sub CommandButton1_Click()
' Create and set the file dialog object.
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear ' Clear all the filters (if applied before).
' Give the dialog box a title, word for doc or Excel for excel files.
.Title = "Select a jpg File"
' Apply filter to show only a particular type of files.
' For example, *.doc? to show only word files or
' *.xlsx? to show only excel files.
.Filters.Add "Image Files", "*.jpg,*.bmp", 1
' Do not allow users to select more than one file.
' Set the value as "True" to select multiple files.
.AllowMultiSelect = False
' Show the file.
If .Show = True Then
TextBox1 = .SelectedItems(1) ' Get the complete file path.
TextBox2 = Dir(.SelectedItems(1)) ' Get the file name.
Image1.Picture = LoadPicture(.SelectedItems(1))
End If
End With
End Sub
کامنت