fork download
  1. Private Sub Workbook_Open()
  2. Dim wsh As Object
  3. Dim dPath As String
  4. Dim sPath As String
  5. Dim varFileName As Variant
  6. Dim rc As Long
  7. Dim targetbook As Workbook
  8.  
  9. Set wsh = CreateObject("WScript.Shell")
  10. dPath = wsh.SpecialFolders("Desktop")
  11. Set wsh = Nothing
  12.  
  13. ActiveSheet.Cells.Clear
  14. sPath = Application.Path & "\MSACCESS.EXE"
  15. MsgBox "ファイル選択ダイアログが開きますので、" & vbCrLf & "読込むCSVファイルを指定してください"
  16. varFileName = Application.GetOpenFilename(FileFilter:="CSVファイル(*.csv),*.csv", _
  17. Title:="CSVファイルの選択")
  18. If varFileName <> "False" Then
  19. Set targetbook = Workbooks.Open(varFileName)
  20. Else
  21. Exit Sub
  22. End If
  23. targetbook.ActiveSheet.Cells.Copy ThisWorkbook.ActiveSheet.Cells
  24. targetbook.Close SaveChanges:=False
  25. Set targetbook = Nothing
  26. ThisWorkbook.Save
  27. rc = Shell(sPath & " " & dPath & "\input.xlsm", vbNormalFocus)
  28. If rc = 0 Then MsgBox "起動に失敗しました"
  29. End Sub
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty