Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. Private Sub CommandButton1_Click()
  2. Dim fd As Office.FileDialog
  3.  
  4. z1 = UserForm2.Label1.Caption // Data from the Excel Sheet
  5. z2 = UserForm2.Label2.Caption
  6. z3 = UserForm2.Label3.Caption
  7. z4 = UserForm2.Label4.Caption
  8. z5 = UserForm2.Label5.Caption
  9. z6 = UserForm2.Label6.Caption
  10.  
  11. Set fd = Application.FileDialog(msoFileDialogFilePicker)
  12.  
  13.  
  14.  
  15. With fd
  16.  
  17. .AllowMultiSelect = False
  18. .Filters.Add "All", "*.*"
  19.  
  20. If .Show = True Then
  21. txtFileName = .SelectedItems(1)
  22. Open txtFileName For Output As #1
  23. Print #1, z6
  24. Print #1, '
  25. Print #1, "Ex1 = "; z1
  26. Print #1, '
  27. Print #1, "Ex2 = "; z2
  28. Print #1, '
  29. Print #1, "Ex3 = "; z3
  30. Print #1, '
  31. Print #1, "Ex4 = "; z4
  32. Print #1, '
  33. Print #1, "Ex5 = "; z5
  34.  
  35. MsgBox "The data has been exported"
  36.  
  37. Close #1
  38. UserForm2.Hide
  39. UserForm1.Hide
  40. End If
  41.  
  42. End With
  43.  
  44.  
  45.  
  46. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement