Em có ví dụ này nhờ mọi người xem dùm cho. Em muốn lấy đường dẫn file sẽ mở trả vào textbox trên userform.
(Câu hỏi cụ thể trong file đính kèm)
Private Sub CommandButton2_Click()
Dim vFile
vFile = Application.GetOpenFilename("Excel Files, *.xls;*.xlsx;*.xlsm")
If TypeName(vFile) = "String" Then TextBox1.Text = vFile
End Sub
Code cho CommandButton:
Nếu là tôi thì tôi không dùng CommandButton + TextBox mà chỉ cần 1 ComboBox là đủ ---> Xem file của tôi đâyPHP:Private Sub CommandButton2_Click() Dim vFile vFile = Application.GetOpenFilename("Excel Files, *.xls;*.xlsx;*.xlsm") If TypeName(vFile) = "String" Then TextBox1.Text = vFile End Sub
Option Explicit
Dim fName As String
Private Sub CommandButton1_Click()
Workbooks.Open (fName)
Unload UserForm1
End Sub
Private Sub CommandButton2_Click()
fName = Application.GetOpenFilename()
TextBox1 = fName
End Sub
Private Sub CommandButton3_Click()
Unload Me
End Sub
Em có ví dụ này nhờ mọi người xem dùm cho. Em muốn lấy đường dẫn file sẽ mở trả vào textbox trên userform.
(Câu hỏi cụ thể trong file đính kèm)
Sub layduongdan()
Dim FileToOpen
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls;*.xlsx;*.xlsm")
If FileToOpen <> False Then
MsgBox FileToOpen
End If
End Sub
Sub MoFile()
Dim FileToOpen
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls;*.xlsx;*.xlsm")
If FileToOpen <> False Then
Workbooks.Open FileToOpen
End If
End Sub
Sub vidu()
Dim FileToOpen
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls;*.xlsx;*.xlsm")
If FileToOpen <> False Then
MsgBox FileToOpen
Workbooks.Open FileToOpen
End If
End Sub
Sub vidu2()
Dim FileToOpen
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls;*.xlsx;*.xlsm")
If FileToOpen <> False Then
MsgBox FileToOpen
Workbooks.Open FileToOpen
MsgBox ActiveWorkbook.Name
End If
End Sub
Lưu fileTo các AC! Em muốn hỏi thêm 1 vấn đề nữa. Em muốn lưu dữ liệu và em đã tạo 1 form nhờ AC xem thêm cho em chút nữa nhé!
Câu hỏi cụ thể trong file đính kèm!
Private Sub CommandButton1_Click()
ActiveWorkbook.SaveAs TextBox1 & "\" & TextBox2 & ".xls"
End Sub
To các AC! Em muốn hỏi thêm 1 vấn đề nữa. Em muốn lưu dữ liệu và em đã tạo 1 form nhờ AC xem thêm cho em chút nữa nhé!
Câu hỏi cụ thể trong file đính kèm!
Dạ, vẫn chưa đúng ý em? Anh gửi file đính kèm cho em nhé!