■5111 / inTopicNo.6) |
Re[4]: プリントダイアログでプリンター設定しても変わらない |
□投稿者/ わかば (3回)-(2007/07/04(Wed) 17:03:11)
|
■No5095 (ぽぴ王子 さん) に返信
■No5096 (魔界の仮面弁士 さん) に返信
>
> いつものコレを貼っておきますね。
> http://jeanne.wankuma.com/tips/programing/releasecom.html
>
ぽぴ王子 さん、魔界の仮面弁士 さん、ご回答ありがとうございます。
上記のURLを参考に記述しました。
Dim xlApp As Excel.Application
xlApp = CreateObject("Excel.Application")
Try
xlApp = New Excel.Application
xlApp.DisplayAlerts = False
Dim xlBooks As Excel.Workbooks = xlApp.Workbooks
Try
Dim xlBook As Excel.Workbook = xlBooks.Open(FilePass, 0)
Try
Dim xlSheets As Excel.Sheets = xlBook.Worksheets
Try
Dim xlSheet As Excel.Worksheet = DirectCast(xlSheets(1), Excel.Worksheet)
Try
Dim xlCells As Excel.Range = xlSheet.Cells
Try
Dim xlRange As Excel.Range = DirectCast(xlCells(6, 4), Excel.Range)
Try
xlApp.Visible = True
System.Threading.Thread.Sleep(1000)
Dim PrintDialog1 As New PrintDialog
PrintDialog1.PrinterSettings = New System.Drawing.Printing.PrinterSettings
If PrintDialog1.ShowDialog() = DialogResult.OK Then
xlApp.ActivePrinter = "プリンタ名"
xlSheet.PrintOut()
End If
System.Threading.Thread.Sleep(1000)
Finally
If Not xlRange Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlRange)
End If
End Try
Finally
If Not xlCells Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlCells)
End If
End Try
Finally
If Not xlSheet Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
End If
End Try
Finally
If Not xlSheets Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheets)
End If
End Try
Finally
If Not xlBook Is Nothing Then
Try
xlBook.Close()
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
End Try
End If
End Try
Finally
If Not xlBooks Is Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBooks)
End If
End Try
Finally
If Not xlApp Is Nothing Then
Try
xlApp.Quit()
Finally
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
End Try
End If
End Try
> xlApp.Dialogs プロパティから、xlDialogPrinterSetup のダイアログを Show するとか。
すみません。自分なりに調べてみたんですが、情けない話し分かりません。
参考になるURL等があれば紹介いただければ幸いです。
|
|