Option Strict Off
Imports System.Data.SqlClient
Imports System.Text.RegularExpressions
Imports Microsoft.Office.Interop.Excel.XlUnderlineStyle
Imports Microsoft.Office.Interop.Excel.Constants
Imports Microsoft.Office.Interop.Excel.XlBordersIndex
Imports Microsoft.Office.Interop.Excel.XlLineStyle
Imports Microsoft.Office.Interop.Excel.XlBorderWeight
Imports Microsoft.Office.Interop.Excel.XlThemeFont
Imports Microsoft.Office.Interop.Excel.XlThemeColor
Imports Microsoft.Office.Interop.Excel.XlWindowState
Imports Microsoft.Office.Interop.Excel
Public Class 樣品標籤批量列印
    Dim conn As New SqlConnection
    Dim da As New SqlDataAdapter
    Dim cmd As New SqlCommand
    Dim ds As New DataSet : Dim ds1 As New DataSet : Dim ds2 As New DataSet : Dim ds4 As New DataSet : Dim ds5 As New DataSet : Dim ds6 As New DataSet
    Dim dr As SqlDataReader
    Dim GGHH As String : Dim DDFF As String
    Dim BBNN1 As Integer : Dim BBNN11 As String : Dim AAWW As String : Dim HHGG As String : Dim X1 As String : Dim X2 As String
    Dim RRTT As New Regex("[\u4e00-\u9fa5]")
    Dim KKOO As Double : Dim N1 As Integer : Dim N2 As Integer : Dim N3 As Integer
    Dim xlApp As Application
    Dim xlBook As Workbook
    Dim xlSheet As Worksheet
    Private Sub Set_DGV3載入前設定()
        DataGridView3.DataSource = Nothing : ds2.Clear()
        DataGridView3.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        DataGridView3.ColumnHeadersHeight = 25
        DataGridView3.AllowUserToAddRows = False
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Private Sub Set_DGV3載入後設定()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd : da.Fill(ds2) : DataGridView3.DataSource = ds2.Tables(0) : conn.Close()
        Set_grid2()
    End Sub
    Private Sub Set_清單2()
        Set_DGV3載入前設定()
        SQL1 = "SELECT METOO選擇按鈕.選擇, 樣品訂單控制表.型體號碼, 樣品訂單控制表.型體名稱, 樣品訂單控制表.ETA AS ETD, 鞋樣素描圖控制表.楦頭編號, 鞋樣素描圖控制表.模具編號, 樣品訂單清單.顏色, 樣品訂單清單.數量, 
                       樣品訂單清單.SIZE, 樣品訂單控制表.SO AS 面料, 樣品訂單控制表.SO AS 大底, 樣品訂單清單.流水號
                FROM 樣品訂單控制表 INNER JOIN 鞋樣素描圖控制表 ON 樣品訂單控制表.型體號碼 = 鞋樣素描圖控制表.型體編號 AND 樣品訂單控制表.型體名稱 = 鞋樣素描圖控制表.型體名稱 INNER JOIN
                     樣品訂單清單 ON 樣品訂單控制表.SO = 樣品訂單清單.SO AND 樣品訂單控制表.版次 = 樣品訂單清單.版次 LEFT OUTER JOIN METOO選擇按鈕 ON 樣品訂單控制表.SO = METOO選擇按鈕.對應
                WHERE (樣品訂單控制表.狀態 LIKE N'" & 樣品進度表分類5 & "') AND (樣品訂單控制表.季節 LIKE N'" & ComboBox1.Text & "') AND (樣品訂單控制表.客戶 LIKE N'" & ComboBox2.Text & "')
                ORDER BY 樣品訂單控制表.型體號碼, 樣品訂單清單.顏色"
        Set_DGV3載入後設定()
    End Sub
    Private Sub Set_grid2()
        DataGridView3.Columns(0).Width = 60 : DataGridView3.Columns(1).Width = 150 : DataGridView3.Columns(2).Width = 150 : DataGridView3.Columns(3).Width = 150 : DataGridView3.Columns(4).Width = 150
        DataGridView3.Columns(5).Width = 150 : DataGridView3.Columns(6).Width = 150 : DataGridView3.Columns(7).Width = 150 : DataGridView3.Columns(8).Width = 150 : DataGridView3.Columns(9).Width = 303
        DataGridView3.Columns(10).Width = 302 : DataGridView3.Columns(11).Visible = False
        DataGridView3.Columns(7).DefaultCellStyle.Format = "#,##0.0"
        DataGridView3.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        DataGridView3.Columns(7).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        DataGridView3.EditMode = DataGridViewEditMode.EditOnEnter
        For i As Integer = 0 To DataGridView3.Rows.Count - 1 : DataGridView3.Rows(i).Cells("選擇").Value = False : Next i
        For i As Integer = 0 To DataGridView3.Rows.Count - 1
            資料數 = DataGridView3.Rows.Count : MyModule1.進度條()
            conn.Close()
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "SELECT TOP (1) 材料名稱 FROM 樣品訂單部件表 
                    WHERE (流水號 LIKE N'" & DataGridView3.Rows(i).Cells("流水號").Value & "') AND (部件 LIKE 'A.%') AND (部件 LIKE '%面料A' OR 部件 LIKE '%面料')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
            If (dr.Read()) Then : DDFF = dr("材料名稱") : Else : DDFF = "" : End If : conn.Close()
            '--------------------------------------------------------------------------------------------
            BBNN1 = DDFF.Length.ToString()
            For II As Integer = 0 To BBNN1 - 1
                If II = 0 Then
                    AAWW = Strings.Left(DDFF, 1)
                    If RRTT.IsMatch(AAWW) Then : Else : BBNN11 = Strings.Left(DDFF, 1) : End If
                Else
                    AAWW = Strings.Mid(DDFF, II + 1, 1) : If RRTT.IsMatch(AAWW) Then : Else : HHGG = BBNN11 : BBNN11 = HHGG & AAWW : End If
                End If
            Next : DataGridView3.Rows(i).Cells("面料").Value = BBNN11
            '--------------------------------------------------------------------------------------------
            conn.Close()
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "SELECT TOP (1) 材料名稱 FROM 樣品訂單部件表 
                    WHERE (流水號 LIKE N'" & DataGridView3.Rows(i).Cells("流水號").Value & "') AND (部件 LIKE N'E.OUTSOLE 大底')"
            cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
            If (dr.Read()) Then : DDFF = dr("材料名稱") : Else : DDFF = "" : End If : conn.Close()
            '--------------------------------------------------------------------------------------------
            BBNN1 = DDFF.Length.ToString()
            For II As Integer = 0 To BBNN1 - 1
                If II = 0 Then
                    AAWW = Strings.Left(DDFF, 1)
                    If RRTT.IsMatch(AAWW) Then : Else : BBNN11 = Strings.Left(DDFF, 1) : End If
                Else
                    AAWW = Strings.Mid(DDFF, II + 1, 1) : If RRTT.IsMatch(AAWW) Then : Else : HHGG = BBNN11 : BBNN11 = HHGG & AAWW : End If
                End If
            Next : DataGridView3.Rows(i).Cells("大底").Value = BBNN11
            '--------------------------------------------------------------------------------------------
        Next : WINPROFIT_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
    End Sub
    Private Sub ComboBox1下拉表單資料載入()
        conn.Close()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT SEASON FROM 季節清單 ORDER BY SEASON"
        cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
        ComboBox1.Items.Clear() : While (dr.Read()) : ComboBox1.Items.Add(dr("SEASON")) : End While : conn.Close()
    End Sub
    Private Sub ComboBox2下拉表單資料載入()
        conn.Close()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 客戶簡稱 FROM 客戶控制表 ORDER BY 客戶簡稱"
        cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
        ComboBox2.Items.Clear() : While (dr.Read()) : ComboBox2.Items.Add(dr("客戶簡稱")) : End While : conn.Close()
    End Sub
    Private Sub 樣品標籤批量列印_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        ComboBox1下拉表單資料載入() : ComboBox2下拉表單資料載入()
    End Sub
    Private Sub DataGridView3_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles DataGridView3.RowPostPaint
        Dim linePen As New Pen(Color.Blue, 2)
        If e.RowIndex = DataGridView3.Rows.Count - 1 Then
            Exit Sub
        Else
            If DataGridView3(2, e.RowIndex).Value.ToString <> DataGridView3(2, e.RowIndex + 1).Value.ToString Then
                Dim startX As Integer = IIf(DataGridView3.RowHeadersVisible, DataGridView3.RowHeadersWidth, 0)
                Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                Dim endX As Integer = startX + DataGridView3.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - DataGridView3.HorizontalScrollingOffset
                e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
                Exit Sub
            End If
        End If
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text <> "" And ComboBox2.Text <> "" Then : Set_清單2() : End If
    End Sub
    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        If ComboBox1.Text <> "" And ComboBox2.Text <> "" Then : Set_清單2() : End If
    End Sub
    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        For i As Integer = 0 To DataGridView3.Rows.Count - 1 : DataGridView3.Rows(i).Cells("選擇").Value = True : Next i
    End Sub
    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        For i As Integer = 0 To DataGridView3.Rows.Count - 1 : DataGridView3.Rows(i).Cells("選擇").Value = False : Next i
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        xlApp = CType(CreateObject("Excel.Application"), Application)
        xlBook = xlApp.Workbooks.Add
        xlApp.DisplayAlerts = True
        xlBook.Activate()
        xlSheet = NewMethod(xlBook)
        xlSheet.Activate()
        xlApp.Visible = True
        xlApp.Application.WindowState = xlMaximized

        N1 = 0 : N2 = 0 : N3 = 0
        For i As Integer = 0 To DataGridView3.Rows.Count - 1
            For ii As Integer = 1 To DataGridView3.Rows(i).Cells("數量").Value * 2
                If DataGridView3.Rows(i).Cells("選擇").Value = True Then
                    If DataGridView3.Rows(i).Cells("數量").Value <> 0 Then
                        xlSheet.Cells(1 + N1, 1 + N3) = "        ME TOO"
                        xlSheet.Cells(2 + N1, 1 + N3) = "                     " & 樣品進度表分類5
                        xlSheet.Cells(3 + N1, 1 + N3) = "Season" : xlSheet.Cells(3 + N1, 2 + N3) = ComboBox1.Text
                        xlSheet.Cells(4 + N1, 1 + N3) = "Customer:" : xlSheet.Cells(4 + N1, 2 + N3) = ComboBox2.Text
                        xlSheet.Cells(5 + N1, 1 + N3) = "Styie#/Name:"
                        xlSheet.Cells(5 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("型體號碼").Value : xlSheet.Cells(6 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("型體名稱").Value
                        xlSheet.Cells(7 + N1, 1 + N3) = "Last/Const:" : xlSheet.Cells(7 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("模具編號").Value
                        xlSheet.Cells(8 + N1, 1 + N3) = "Upper Mtrl:" : xlSheet.Cells(8 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("面料").Value
                        xlSheet.Cells(9 + N1, 1 + N3) = "Color:" : xlSheet.Cells(9 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("顏色").Value
                        xlSheet.Cells(10 + N1, 1 + N3) = "Outsole:" : xlSheet.Cells(10 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("大底").Value
                        xlSheet.Cells(11 + N1, 1 + N3) = "Size:" : xlSheet.Cells(11 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("SIZE").Value
                        xlSheet.Cells(12 + N1, 1 + N3) = "Date:" : xlSheet.Cells(12 + N1, 2 + N3) = DataGridView3.Rows(i).Cells("ETD").Value
                        AA(xlApp, xlSheet)
                        N1 = N1 + 12 : N2 = N2 + 1
                        If N2 = 100 Or N2 = 200 Or N2 = 300 Or N2 = 400 Or N2 = 500 Or N2 = 600 Or N2 = 700 Or N2 = 800 Or N2 = 900 Or N2 = 1000 Or N2 = 1100 Or N2 = 1200 Or N2 = 1300 Or N2 = 1400 Or N2 = 1500 Or
                           N2 = 1600 Or N2 = 1700 Or N2 = 1800 Or N2 = 1900 Or N2 = 2000 Or N2 = 2100 Or N2 = 2200 Or N2 = 2300 Or N2 = 2400 Or N2 = 2500 Or N2 = 2600 Or N2 = 2700 Or N2 = 2800 Or N2 = 2900 Or
                           N2 = 3000 Or N2 = 3100 Or N2 = 3200 Then
                            N3 = N3 + 2 : N1 = 0
                        End If
                    End If
                End If
            Next
        Next i
        BB(xlApp, xlSheet)
        xlSheet.PageSetup.PrintArea = ""
        xlApp.Cells.Select()
        xlSheet.Range("B1").Select()
        xlApp.Application.WindowState = xlMinimized
        MsgBox("列印完成")
    End Sub
    Private Shared Function NewMethod(xlBook As Workbook) As Worksheet
        Return CType(xlBook.Worksheets.Add, Worksheet)
    End Function
    Private Sub 分行()
        If N2 = 0 Then : X1 = "A" : X2 = "B" : ElseIf N2 = 100 Then : X1 = "C" : X2 = "D" : ElseIf N2 = 200 Then : X1 = "E" : X2 = "F" : ElseIf N2 = 300 Then : X1 = "G" : X2 = "H"
        ElseIf N2 = 400 Then : X1 = "I" : X2 = "J" : ElseIf N2 = 500 Then : X1 = "K" : X2 = "L" : ElseIf N2 = 600 Then : X1 = "M" : X2 = "N" : ElseIf N2 = 700 Then : X1 = "O" : X2 = "P"
        ElseIf N2 = 800 Then : X1 = "Q" : X2 = "R" : ElseIf N2 = 900 Then : X1 = "S" : X2 = "T" : ElseIf N2 = 1000 Then : X1 = "U" : X2 = "V" : ElseIf N2 = 1100 Then : X1 = "W" : X2 = "X"
        ElseIf N2 = 1200 Then : X1 = "Y" : X2 = "Z" : ElseIf N2 = 1300 Then : X1 = "AA" : X2 = "AB" : ElseIf N2 = 1400 Then : X1 = "AC" : X2 = "AD" : ElseIf N2 = 1500 Then : X1 = "AE" : X2 = "AF"
        ElseIf N2 = 1600 Then : X1 = "AG" : X2 = "AH" : ElseIf N2 = 1700 Then : X1 = "AI" : X2 = "AJ" : ElseIf N2 = 1800 Then : X1 = "AK" : X2 = "AL" : ElseIf N2 = 1900 Then : X1 = "AM" : X2 = "AN"
        ElseIf N2 = 2000 Then : X1 = "AO" : X2 = "AP" : ElseIf N2 = 2100 Then : X1 = "AQ" : X2 = "AR" : ElseIf N2 = 2200 Then : X1 = "AS" : X2 = "AT" : ElseIf N2 = 2300 Then : X1 = "AU" : X2 = "AV"
        ElseIf N2 = 2400 Then : X1 = "AW" : X2 = "AX" : ElseIf N2 = 2500 Then : X1 = "AY" : X2 = "AZ" : ElseIf N2 = 2600 Then : X1 = "BA" : X2 = "BB" : ElseIf N2 = 2700 Then : X1 = "BC" : X2 = "BD"
        ElseIf N2 = 2800 Then : X1 = "BE" : X2 = "BF" : ElseIf N2 = 2900 Then : X1 = "BG" : X2 = "BH" : ElseIf N2 = 3000 Then : X1 = "BI" : X2 = "BJ" : ElseIf N2 = 3100 Then : X1 = "BK" : X2 = "BL"
        ElseIf N2 = 3200 Then : X1 = "BM" : X2 = "BN" : End If
    End Sub
    Private Sub AA(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        分行()
        xlSheet.Range(X1 & N1 + 1 & ":" & X2 & N1 + 12).Select()
        With myExcel.Selection.Font : .Name = "新細明體" : .Size = 9 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With

        xlSheet.Range(X1 & N1 + 1 & ":" & X2 & N1 + 1).Select()
        With myExcel.Selection.Font : .Name = "新細明體" : .Size = 20 : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .Underline = xlUnderlineStyleNone : .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With
        myExcel.Selection.Borders(xlDiagonalDown).LineStyle = xlNone : myExcel.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        myExcel.Selection.Borders(xlEdgeLeft).LineStyle = xlNone : myExcel.Selection.Borders(xlEdgeTop).LineStyle = xlNone
        With myExcel.Selection.Borders(xlEdgeBottom) : .LineStyle = xlContinuous : .ColorIndex = 0 : .TintAndShade = 0 : .Weight = xlThin : End With
        myExcel.Selection.Borders(xlEdgeRight).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideVertical).LineStyle = xlNone : myExcel.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

        xlSheet.Range(X2 & N1 + 3 & ":" & X2 & N1 + 12).Select()
        With myExcel.Selection : .HorizontalAlignment = xlCenter : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With

        xlSheet.Range(X2 & N1 + 3 & ":" & X2 & N1 + 12).Select()
        With myExcel.Selection : .HorizontalAlignment = xlLeft : .VerticalAlignment = xlCenter : .WrapText = True : .Orientation = 0 : .AddIndent = False : .IndentLevel = 0
            .ShrinkToFit = False : .ReadingOrder = xlContext : .MergeCells = False : End With

        xlSheet.Range(X1 & N1 + 1 & ":" & X2 & N1 + 2).Select()
        With myExcel.Selection.Font : .Name = "微軟正黑體" : .Strikethrough = False : .Superscript = False : .Subscript = False : .OutlineFont = False : .Shadow = False
            .ThemeColor = xlThemeColorLight1 : .TintAndShade = 0 : .ThemeFont = xlThemeFontNone : End With

        xlSheet.Rows(N1 + 1 & ":" & N1 + 1).Select : myExcel.Selection.RowHeight = 60
        xlSheet.Rows(N1 + 2 & ":" & N1 + 2).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 3 & ":" & N1 + 3).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 4 & ":" & N1 + 4).Select : myExcel.Selection.RowHeight = 25
        xlSheet.Rows(N1 + 5 & ":" & N1 + 5).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 6 & ":" & N1 + 6).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 7 & ":" & N1 + 7).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 8 & ":" & N1 + 8).Select : myExcel.Selection.RowHeight = 35
        xlSheet.Rows(N1 + 9 & ":" & N1 + 9).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 10 & ":" & N1 + 10).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 11 & ":" & N1 + 11).Select : myExcel.Selection.RowHeight = 20
        xlSheet.Rows(N1 + 12 & ":" & N1 + 12).Select : myExcel.Selection.RowHeight = 20

        xlSheet.Cells.Select() : myExcel.Selection.Font.Bold = True
        xlSheet.Columns(X1 & ":" & X1).Select : myExcel.Selection.ColumnWidth = 10
        xlSheet.Columns(X2 & ":" & X2).Select : myExcel.Selection.ColumnWidth = 20
    End Sub
    Private Sub BB(ByVal myExcel As Application, ByVal xlSheet As Worksheet)
        myExcel.Application.PrintCommunication = False
        With myExcel.ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        myExcel.Application.PrintCommunication = True
        myExcel.Application.PrintCommunication = False
        With myExcel.ActiveSheet.PageSetup
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = myExcel.Application.InchesToPoints(0)
            .RightMargin = myExcel.Application.InchesToPoints(0)
            .TopMargin = myExcel.Application.InchesToPoints(0.0393700787401575)
            .BottomMargin = myExcel.Application.InchesToPoints(0.0393700787401575)
            .HeaderMargin = myExcel.Application.InchesToPoints(0)
            .FooterMargin = myExcel.Application.InchesToPoints(0)
            .PrintHeadings = False
            .PrintGridlines = False
            .CenterHorizontally = True
            .CenterVertically = True
            .Draft = False
            .FirstPageNumber = xlAutomatic
            .BlackAndWhite = False
            .Zoom = 55
            .OddAndEvenPagesHeaderFooter = False
            .DifferentFirstPageHeaderFooter = False
            .ScaleWithDocHeaderFooter = True
            .AlignMarginsHeaderFooter = True
            .EvenPage.LeftHeader.Text = ""
            .EvenPage.CenterHeader.Text = ""
            .EvenPage.RightHeader.Text = ""
            .EvenPage.LeftFooter.Text = ""
            .EvenPage.CenterFooter.Text = ""
            .EvenPage.RightFooter.Text = ""
            .FirstPage.LeftHeader.Text = ""
            .FirstPage.CenterHeader.Text = ""
            .FirstPage.RightHeader.Text = ""
            .FirstPage.LeftFooter.Text = ""
            .FirstPage.CenterFooter.Text = ""
            .FirstPage.RightFooter.Text = ""
        End With
        myExcel.Application.PrintCommunication = True
    End Sub
End Class