Menggunakan Excel VBA 2010 - Saya hanya mencoba membuka folder melalui sub. Apa yang saya lakukan salah di sini?
VBA
Sub openFolder()
Dim preFolder As String, theFolder As String, fullPath as String
theFolder = Left(Range("T12").Value, 8)
preFolder = Left(Range("T12").Value, 5) & "xxx"
fullPath = "P:\Engineering\031 Electronic Job Folders\" & preFolder & "\" & theFolder
Shell(theFolder, "P:\Engineering\031 Electronic Job Folders\" & preFolder, vbNormalFocus)
End Sub
Jika Anda ingin membuka file explorer windows, Anda harus memanggil explorer.exe
Call Shell("explorer.exe" & " " & "P:\Engineering", vbNormalFocus)
Syxntax yang setara
Shell "explorer.exe" & " " & "P:\Engineering", vbNormalFocus
Saya menggunakan ini untuk membuka buku kerja dan kemudian menyalin data buku kerja itu ke templat.
Private Sub CommandButton24_Click()
Set Template = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "I:\Group - Finance" ' Yu can select any folder you want
.Filters.Clear
.Title = "Your Title"
If Not .Show Then
MsgBox "No file selected.": Exit Sub
End If
Workbooks.OpenText .SelectedItems(1)
'Di bawah ini adalah untuk menyalin file ke dalam lembar baru di buku kerja dan menempelkan nilai-nilai itu di lembar 1
Set myfile = ActiveWorkbook
ActiveWorkbook.Sheets(1).Copy after:=ThisWorkbook.Sheets(1)
myfile.Close
Template.Activate
ActiveSheet.Cells.Select
Selection.Copy
Sheets("Sheet1").Select
Cells.Select
ActiveSheet.Paste
End With