Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'win32ole'
- AcOutputReport = 3
- AcViewPreview = 2
- AcFormatXLS = "Microsoft Excel (*.xls)"
- AcFormatRTF = "Rich Text Format (*.rtf)"
- AcFormatSNP = "Snapshot Format (*.snp)"
- AcFormatHTML = "HTML (*.html)"
- acApp = WIN32OLE.new('Access.Application')
- acApp.OpenCurrentDatabase(ARGV[0])
- acApp.Visible = true
- strReportName = ARGV[1]
- case ARGV[3].upcase
- when "XLS"
- acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatXLS, ARGV[2] + "autoxls.xls", true)
- when "RTF"
- acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatRTF, ARGV[2] + "autortf.rtf", true)
- when "SNAP"
- acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatSNP, ARGV[2] + "autosnap.snp", true)
- when "HTML"
- acApp.DoCmd.OutputTo(AcOutputReport, strReportName, AcFormatHTML, ARGV[2] + "autohtml.htm", true)
- else
- acApp.DoCmd.OpenReport(strReportName, AcViewPreview)
- end
- case ARGV[3].upcase
- when "XLS", "RTF", "SNAP", "HTML"
- acApp.Quit
- end
- #実行形式
- #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "XLS"
- #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "RTF"
- #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "SNAP"
- #ruby OpenReport.rb "s:\test.mdb" "test_report" "s:\" "HTML"
- #ruby OpenReport.rb "s:\test.mdb" "test_report" "" ""
Add Comment
Please, Sign In to add comment