Guest User

Untitled

a guest
Oct 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. require 'win32ole'
  2.  
  3. AcOutputReport = 3
  4. AcViewPreview = 2
  5. AcFormatXLS = "Microsoft Excel (*.xls)"
  6. AcFormatRTF = "Rich Text Format (*.rtf)"
  7. AcFormatSNP = "Snapshot Format (*.snp)"
  8. AcFormatHTML = "HTML (*.html)"
  9.  
  10. acApp = WIN32OLE.new('Access.Application')
  11. acApp.OpenCurrentDatabase(ARGV[0])
  12. acApp.Visible = true
  13.  
  14. strReportName = ARGV[1]
  15.  
  16. case ARGV[3].upcase
  17. when "XLS"
  18. acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatXLS, ARGV[2] + "autoxls.xls", true)
  19. when "RTF"
  20. acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatRTF, ARGV[2] + "autortf.rtf", true)
  21. when "SNAP"
  22. acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatSNP, ARGV[2] + "autosnap.snp", true)
  23. when "HTML"
  24. acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatHTML, ARGV[2] + "autohtml.htm", true)
  25. else
  26. acApp.DoCmd.OpenReport(strReportName, AcViewPreview)
  27. end
  28.  
  29. case ARGV[3].upcase
  30. when "XLS", "RTF", "SNAP", "HTML"
  31. acApp.Quit
  32. end
  33.  
  34. #実行形式
  35. #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "XLS"
  36. #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "RTF"
  37. #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "SNAP"
  38. #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "HTML"
  39. #ruby OpenReport.rb "s:\test.mdb" "test_report" "" ""
Add Comment
Please, Sign In to add comment