Selection.ShapeRange.ScaleWidth 0.27, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleHeight 0.27, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementLeft -5.22
Selection.ShapeRange.IncrementTop 0.75
为什么打印的时候第一次没有问题。
第二次就大小不对了。
其它的地方都对。
感觉是变量没有释放
但
Set Selection = Nothing
Set xsheet = Nothing
Set xlbook = Nothing
Set X = Nothing
好像没问题啊
5 个解决方案
#1
天啊!
没人会?
帮忙啊!
没人会?
帮忙啊!
#2
看是不是xsheet变量作用域的问题.
#3
On Error Resume Next
Dim X As Excel.Application
Dim xsheet As Excel.Worksheet
Dim xlbook As Excel.Workbook
Dim i As Integer
Dim qu, nw, am As Double
Set X = New Excel.Application
X.Visible = True
Set xlbook = X.Workbooks.Add
Set xsheet = X.ActiveSheet
qu = 0
nw = 0
am = 0
With xsheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD."
.LeftMargin = Application.InchesToPoints(0.15748031496063)
.RightMargin = Application.InchesToPoints(0.15748031496063)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.15748031496063)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 300 '???????????????????????????????
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
xsheet.Pictures.Insert(App.Path & "\pic\LOGOPIC.bmp").Select
Selection.ShapeRange.ScaleWidth 0.27, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleHeight 0.27, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementLeft -5.22
Selection.ShapeRange.IncrementTop 0.75
这是原程序,帮忙看看
Dim X As Excel.Application
Dim xsheet As Excel.Worksheet
Dim xlbook As Excel.Workbook
Dim i As Integer
Dim qu, nw, am As Double
Set X = New Excel.Application
X.Visible = True
Set xlbook = X.Workbooks.Add
Set xsheet = X.ActiveSheet
qu = 0
nw = 0
am = 0
With xsheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD."
.LeftMargin = Application.InchesToPoints(0.15748031496063)
.RightMargin = Application.InchesToPoints(0.15748031496063)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.15748031496063)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 300 '???????????????????????????????
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
xsheet.Pictures.Insert(App.Path & "\pic\LOGOPIC.bmp").Select
Selection.ShapeRange.ScaleWidth 0.27, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleHeight 0.27, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementLeft -5.22
Selection.ShapeRange.IncrementTop 0.75
这是原程序,帮忙看看
#4
xsheet.Columns("B:B").ColumnWidth = 13.75
With Range("B6").Font
.Name = "宋体"
.Size = 20
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(6, 2) = "INVOICE"
xsheet.Cells(6, 3) = "& PACKING LIST"
With Range("A9").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(9, 1) = "SELLER:"
xsheet.Columns("A:A").ColumnWidth = 29.13
xsheet.Rows("10:10").RowHeight = 63.75
xsheet.Rows("14:14").RowHeight = 63.75
With Range("A13").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("A10", "A23")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(10, 1) = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD. AULAN INDUSTRIAL PARK,ID-32 FREE TRADE ZONE DALIAN ,CHINA"
xsheet.Cells(11, 1) = "TEL: 86-411-87328545"
xsheet.Cells(13, 1) = "BUYER:"
xsheet.Cells(14, 1) = Trim(Combo2.Text) & Chr(10) & Trim(Text1(0).Text)
xsheet.Cells(15, 1) = "TEL: " & Trim(Text1(1).Text)
With Range("D9", "D10").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("D9", "D10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Range("F10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Columns("C:C").ColumnWidth = 6.63
xsheet.Columns("E:E").ColumnWidth = 10.25
xsheet.Cells(9, 4) = "DATE:"
xsheet.Cells(9, 5) = DTPicker1.Value
xsheet.Cells(10, 4) = "INVOICE NO:"
xsheet.Cells(10, 6) = Trim(Combo1.Text)
Rows("18:18").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("18:18").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeLeft).LineStyle = xlNone
With Rows("18:18").Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("18:18").Borders(xlEdgeBottom).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeRight).LineStyle = xlNone
Rows("18:18").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.Cells(18, 1) = "DESCRIPTION"
xsheet.Cells(18, 2) = "QUANTITY"
xsheet.Cells(18, 3) = "N.W"
xsheet.Cells(18, 5) = "UNIT PRICE"
xsheet.Cells(18, 7) = "AMOUNT"
xsheet.Cells(19, 5) = "(USD)"
xsheet.Cells(19, 7) = "(USD)"
Rows("19:19").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("19:19").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeLeft).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeTop).LineStyle = xlNone
With Rows("19:19").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("19:19").Borders(xlEdgeRight).LineStyle = xlNone
Rows("19:19").Borders(xlInsideVertical).LineStyle = xlNone
For i = 1 To MSFGrid1.Rows - 1
xsheet.Cells(i + 19, 1) = MSFGrid1.TextMatrix(i, 1) & Space(1) & MSFGrid1.TextMatrix(i, 2)
xsheet.Cells(i + 19, 2) = MSFGrid1.TextMatrix(i, 3) & "PCS"
qu = qu + MSFGrid1.TextMatrix(i, 3)
xsheet.Cells(i + 19, 3) = MSFGrid1.TextMatrix(i, 4)
nw = nw + MSFGrid1.TextMatrix(i, 4)
xsheet.Cells(i + 19, 5) = MSFGrid1.TextMatrix(i, 5)
xsheet.Cells(i + 19, 7) = MSFGrid1.TextMatrix(i, 6)
am = am + MSFGrid1.TextMatrix(i, 6)
Next
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalDown).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalUp).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeLeft).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeTop).LineStyle = xlNone
With Rows(i + 18 & ":" & i + 18).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeRight).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlInsideVertical).LineStyle = xlNone
Rows(i + 19 & ":" & i + 19).RowHeight = 6.75
xsheet.Cells(i + 20, 1) = "TOTAL:"
xsheet.Cells(i + 20, 2) = qu
xsheet.Cells(i + 20, 3) = nw
xsheet.Cells(i + 20, 7) = am
With Range("B18:G" & i + 20)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(41, 1) = "NET WEIGHT:" & Space(6) & Trim(Text1(2).Text) & " KGS"
xsheet.Cells(42, 1) = "GROSS WEIGHT:" & Space(6) & Trim(Text1(3).Text) & " KGS"
xsheet.Cells(43, 1) = "TOTAL:" & Space(6) & Trim(Text1(4).Text) & " PACKAGES"
xsheet.Cells(39, 3) = "CIF DALIAN"
Range("B44:G44").Borders(xlDiagonalDown).LineStyle = xlNone
Range("B44:G44").Borders(xlDiagonalUp).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeLeft).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeTop).LineStyle = xlNone
With Range("B44:G44").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("B44:G44").Borders(xlEdgeRight).LineStyle = xlNone
Range("B44:G44").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.PrintPreview
Set X = Nothing
Set xsheet = Nothing
Set xlbook = Nothing
With Range("B6").Font
.Name = "宋体"
.Size = 20
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(6, 2) = "INVOICE"
xsheet.Cells(6, 3) = "& PACKING LIST"
With Range("A9").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(9, 1) = "SELLER:"
xsheet.Columns("A:A").ColumnWidth = 29.13
xsheet.Rows("10:10").RowHeight = 63.75
xsheet.Rows("14:14").RowHeight = 63.75
With Range("A13").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("A10", "A23")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(10, 1) = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD. AULAN INDUSTRIAL PARK,ID-32 FREE TRADE ZONE DALIAN ,CHINA"
xsheet.Cells(11, 1) = "TEL: 86-411-87328545"
xsheet.Cells(13, 1) = "BUYER:"
xsheet.Cells(14, 1) = Trim(Combo2.Text) & Chr(10) & Trim(Text1(0).Text)
xsheet.Cells(15, 1) = "TEL: " & Trim(Text1(1).Text)
With Range("D9", "D10").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("D9", "D10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Range("F10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Columns("C:C").ColumnWidth = 6.63
xsheet.Columns("E:E").ColumnWidth = 10.25
xsheet.Cells(9, 4) = "DATE:"
xsheet.Cells(9, 5) = DTPicker1.Value
xsheet.Cells(10, 4) = "INVOICE NO:"
xsheet.Cells(10, 6) = Trim(Combo1.Text)
Rows("18:18").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("18:18").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeLeft).LineStyle = xlNone
With Rows("18:18").Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("18:18").Borders(xlEdgeBottom).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeRight).LineStyle = xlNone
Rows("18:18").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.Cells(18, 1) = "DESCRIPTION"
xsheet.Cells(18, 2) = "QUANTITY"
xsheet.Cells(18, 3) = "N.W"
xsheet.Cells(18, 5) = "UNIT PRICE"
xsheet.Cells(18, 7) = "AMOUNT"
xsheet.Cells(19, 5) = "(USD)"
xsheet.Cells(19, 7) = "(USD)"
Rows("19:19").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("19:19").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeLeft).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeTop).LineStyle = xlNone
With Rows("19:19").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("19:19").Borders(xlEdgeRight).LineStyle = xlNone
Rows("19:19").Borders(xlInsideVertical).LineStyle = xlNone
For i = 1 To MSFGrid1.Rows - 1
xsheet.Cells(i + 19, 1) = MSFGrid1.TextMatrix(i, 1) & Space(1) & MSFGrid1.TextMatrix(i, 2)
xsheet.Cells(i + 19, 2) = MSFGrid1.TextMatrix(i, 3) & "PCS"
qu = qu + MSFGrid1.TextMatrix(i, 3)
xsheet.Cells(i + 19, 3) = MSFGrid1.TextMatrix(i, 4)
nw = nw + MSFGrid1.TextMatrix(i, 4)
xsheet.Cells(i + 19, 5) = MSFGrid1.TextMatrix(i, 5)
xsheet.Cells(i + 19, 7) = MSFGrid1.TextMatrix(i, 6)
am = am + MSFGrid1.TextMatrix(i, 6)
Next
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalDown).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalUp).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeLeft).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeTop).LineStyle = xlNone
With Rows(i + 18 & ":" & i + 18).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeRight).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlInsideVertical).LineStyle = xlNone
Rows(i + 19 & ":" & i + 19).RowHeight = 6.75
xsheet.Cells(i + 20, 1) = "TOTAL:"
xsheet.Cells(i + 20, 2) = qu
xsheet.Cells(i + 20, 3) = nw
xsheet.Cells(i + 20, 7) = am
With Range("B18:G" & i + 20)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(41, 1) = "NET WEIGHT:" & Space(6) & Trim(Text1(2).Text) & " KGS"
xsheet.Cells(42, 1) = "GROSS WEIGHT:" & Space(6) & Trim(Text1(3).Text) & " KGS"
xsheet.Cells(43, 1) = "TOTAL:" & Space(6) & Trim(Text1(4).Text) & " PACKAGES"
xsheet.Cells(39, 3) = "CIF DALIAN"
Range("B44:G44").Borders(xlDiagonalDown).LineStyle = xlNone
Range("B44:G44").Borders(xlDiagonalUp).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeLeft).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeTop).LineStyle = xlNone
With Range("B44:G44").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("B44:G44").Borders(xlEdgeRight).LineStyle = xlNone
Range("B44:G44").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.PrintPreview
Set X = Nothing
Set xsheet = Nothing
Set xlbook = Nothing
#5
没看明白程序,但我觉得你少一条语句。 Range("某个单元格").Select
#1
天啊!
没人会?
帮忙啊!
没人会?
帮忙啊!
#2
看是不是xsheet变量作用域的问题.
#3
On Error Resume Next
Dim X As Excel.Application
Dim xsheet As Excel.Worksheet
Dim xlbook As Excel.Workbook
Dim i As Integer
Dim qu, nw, am As Double
Set X = New Excel.Application
X.Visible = True
Set xlbook = X.Workbooks.Add
Set xsheet = X.ActiveSheet
qu = 0
nw = 0
am = 0
With xsheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD."
.LeftMargin = Application.InchesToPoints(0.15748031496063)
.RightMargin = Application.InchesToPoints(0.15748031496063)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.15748031496063)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 300 '???????????????????????????????
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
xsheet.Pictures.Insert(App.Path & "\pic\LOGOPIC.bmp").Select
Selection.ShapeRange.ScaleWidth 0.27, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleHeight 0.27, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementLeft -5.22
Selection.ShapeRange.IncrementTop 0.75
这是原程序,帮忙看看
Dim X As Excel.Application
Dim xsheet As Excel.Worksheet
Dim xlbook As Excel.Workbook
Dim i As Integer
Dim qu, nw, am As Double
Set X = New Excel.Application
X.Visible = True
Set xlbook = X.Workbooks.Add
Set xsheet = X.ActiveSheet
qu = 0
nw = 0
am = 0
With xsheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD."
.LeftMargin = Application.InchesToPoints(0.15748031496063)
.RightMargin = Application.InchesToPoints(0.15748031496063)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.15748031496063)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 300 '???????????????????????????????
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
xsheet.Pictures.Insert(App.Path & "\pic\LOGOPIC.bmp").Select
Selection.ShapeRange.ScaleWidth 0.27, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleHeight 0.27, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementLeft -5.22
Selection.ShapeRange.IncrementTop 0.75
这是原程序,帮忙看看
#4
xsheet.Columns("B:B").ColumnWidth = 13.75
With Range("B6").Font
.Name = "宋体"
.Size = 20
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(6, 2) = "INVOICE"
xsheet.Cells(6, 3) = "& PACKING LIST"
With Range("A9").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(9, 1) = "SELLER:"
xsheet.Columns("A:A").ColumnWidth = 29.13
xsheet.Rows("10:10").RowHeight = 63.75
xsheet.Rows("14:14").RowHeight = 63.75
With Range("A13").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("A10", "A23")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(10, 1) = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD. AULAN INDUSTRIAL PARK,ID-32 FREE TRADE ZONE DALIAN ,CHINA"
xsheet.Cells(11, 1) = "TEL: 86-411-87328545"
xsheet.Cells(13, 1) = "BUYER:"
xsheet.Cells(14, 1) = Trim(Combo2.Text) & Chr(10) & Trim(Text1(0).Text)
xsheet.Cells(15, 1) = "TEL: " & Trim(Text1(1).Text)
With Range("D9", "D10").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("D9", "D10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Range("F10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Columns("C:C").ColumnWidth = 6.63
xsheet.Columns("E:E").ColumnWidth = 10.25
xsheet.Cells(9, 4) = "DATE:"
xsheet.Cells(9, 5) = DTPicker1.Value
xsheet.Cells(10, 4) = "INVOICE NO:"
xsheet.Cells(10, 6) = Trim(Combo1.Text)
Rows("18:18").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("18:18").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeLeft).LineStyle = xlNone
With Rows("18:18").Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("18:18").Borders(xlEdgeBottom).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeRight).LineStyle = xlNone
Rows("18:18").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.Cells(18, 1) = "DESCRIPTION"
xsheet.Cells(18, 2) = "QUANTITY"
xsheet.Cells(18, 3) = "N.W"
xsheet.Cells(18, 5) = "UNIT PRICE"
xsheet.Cells(18, 7) = "AMOUNT"
xsheet.Cells(19, 5) = "(USD)"
xsheet.Cells(19, 7) = "(USD)"
Rows("19:19").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("19:19").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeLeft).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeTop).LineStyle = xlNone
With Rows("19:19").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("19:19").Borders(xlEdgeRight).LineStyle = xlNone
Rows("19:19").Borders(xlInsideVertical).LineStyle = xlNone
For i = 1 To MSFGrid1.Rows - 1
xsheet.Cells(i + 19, 1) = MSFGrid1.TextMatrix(i, 1) & Space(1) & MSFGrid1.TextMatrix(i, 2)
xsheet.Cells(i + 19, 2) = MSFGrid1.TextMatrix(i, 3) & "PCS"
qu = qu + MSFGrid1.TextMatrix(i, 3)
xsheet.Cells(i + 19, 3) = MSFGrid1.TextMatrix(i, 4)
nw = nw + MSFGrid1.TextMatrix(i, 4)
xsheet.Cells(i + 19, 5) = MSFGrid1.TextMatrix(i, 5)
xsheet.Cells(i + 19, 7) = MSFGrid1.TextMatrix(i, 6)
am = am + MSFGrid1.TextMatrix(i, 6)
Next
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalDown).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalUp).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeLeft).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeTop).LineStyle = xlNone
With Rows(i + 18 & ":" & i + 18).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeRight).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlInsideVertical).LineStyle = xlNone
Rows(i + 19 & ":" & i + 19).RowHeight = 6.75
xsheet.Cells(i + 20, 1) = "TOTAL:"
xsheet.Cells(i + 20, 2) = qu
xsheet.Cells(i + 20, 3) = nw
xsheet.Cells(i + 20, 7) = am
With Range("B18:G" & i + 20)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(41, 1) = "NET WEIGHT:" & Space(6) & Trim(Text1(2).Text) & " KGS"
xsheet.Cells(42, 1) = "GROSS WEIGHT:" & Space(6) & Trim(Text1(3).Text) & " KGS"
xsheet.Cells(43, 1) = "TOTAL:" & Space(6) & Trim(Text1(4).Text) & " PACKAGES"
xsheet.Cells(39, 3) = "CIF DALIAN"
Range("B44:G44").Borders(xlDiagonalDown).LineStyle = xlNone
Range("B44:G44").Borders(xlDiagonalUp).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeLeft).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeTop).LineStyle = xlNone
With Range("B44:G44").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("B44:G44").Borders(xlEdgeRight).LineStyle = xlNone
Range("B44:G44").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.PrintPreview
Set X = Nothing
Set xsheet = Nothing
Set xlbook = Nothing
With Range("B6").Font
.Name = "宋体"
.Size = 20
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(6, 2) = "INVOICE"
xsheet.Cells(6, 3) = "& PACKING LIST"
With Range("A9").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
xsheet.Cells(9, 1) = "SELLER:"
xsheet.Columns("A:A").ColumnWidth = 29.13
xsheet.Rows("10:10").RowHeight = 63.75
xsheet.Rows("14:14").RowHeight = 63.75
With Range("A13").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("A10", "A23")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(10, 1) = "DALIAN F.T.Z.ATRYZ TRADE AND INDUSTRIES CO.,LTD. AULAN INDUSTRIAL PARK,ID-32 FREE TRADE ZONE DALIAN ,CHINA"
xsheet.Cells(11, 1) = "TEL: 86-411-87328545"
xsheet.Cells(13, 1) = "BUYER:"
xsheet.Cells(14, 1) = Trim(Combo2.Text) & Chr(10) & Trim(Text1(0).Text)
xsheet.Cells(15, 1) = "TEL: " & Trim(Text1(1).Text)
With Range("D9", "D10").Font
.Name = "宋体"
.Size = 14
.Bold = True
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With Range("D9", "D10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Range("F10")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Columns("C:C").ColumnWidth = 6.63
xsheet.Columns("E:E").ColumnWidth = 10.25
xsheet.Cells(9, 4) = "DATE:"
xsheet.Cells(9, 5) = DTPicker1.Value
xsheet.Cells(10, 4) = "INVOICE NO:"
xsheet.Cells(10, 6) = Trim(Combo1.Text)
Rows("18:18").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("18:18").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeLeft).LineStyle = xlNone
With Rows("18:18").Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("18:18").Borders(xlEdgeBottom).LineStyle = xlNone
Rows("18:18").Borders(xlEdgeRight).LineStyle = xlNone
Rows("18:18").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.Cells(18, 1) = "DESCRIPTION"
xsheet.Cells(18, 2) = "QUANTITY"
xsheet.Cells(18, 3) = "N.W"
xsheet.Cells(18, 5) = "UNIT PRICE"
xsheet.Cells(18, 7) = "AMOUNT"
xsheet.Cells(19, 5) = "(USD)"
xsheet.Cells(19, 7) = "(USD)"
Rows("19:19").Borders(xlDiagonalDown).LineStyle = xlNone
Rows("19:19").Borders(xlDiagonalUp).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeLeft).LineStyle = xlNone
Rows("19:19").Borders(xlEdgeTop).LineStyle = xlNone
With Rows("19:19").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows("19:19").Borders(xlEdgeRight).LineStyle = xlNone
Rows("19:19").Borders(xlInsideVertical).LineStyle = xlNone
For i = 1 To MSFGrid1.Rows - 1
xsheet.Cells(i + 19, 1) = MSFGrid1.TextMatrix(i, 1) & Space(1) & MSFGrid1.TextMatrix(i, 2)
xsheet.Cells(i + 19, 2) = MSFGrid1.TextMatrix(i, 3) & "PCS"
qu = qu + MSFGrid1.TextMatrix(i, 3)
xsheet.Cells(i + 19, 3) = MSFGrid1.TextMatrix(i, 4)
nw = nw + MSFGrid1.TextMatrix(i, 4)
xsheet.Cells(i + 19, 5) = MSFGrid1.TextMatrix(i, 5)
xsheet.Cells(i + 19, 7) = MSFGrid1.TextMatrix(i, 6)
am = am + MSFGrid1.TextMatrix(i, 6)
Next
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalDown).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlDiagonalUp).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeLeft).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeTop).LineStyle = xlNone
With Rows(i + 18 & ":" & i + 18).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Rows(i + 18 & ":" & i + 18).Borders(xlEdgeRight).LineStyle = xlNone
Rows(i + 18 & ":" & i + 18).Borders(xlInsideVertical).LineStyle = xlNone
Rows(i + 19 & ":" & i + 19).RowHeight = 6.75
xsheet.Cells(i + 20, 1) = "TOTAL:"
xsheet.Cells(i + 20, 2) = qu
xsheet.Cells(i + 20, 3) = nw
xsheet.Cells(i + 20, 7) = am
With Range("B18:G" & i + 20)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xsheet.Cells(41, 1) = "NET WEIGHT:" & Space(6) & Trim(Text1(2).Text) & " KGS"
xsheet.Cells(42, 1) = "GROSS WEIGHT:" & Space(6) & Trim(Text1(3).Text) & " KGS"
xsheet.Cells(43, 1) = "TOTAL:" & Space(6) & Trim(Text1(4).Text) & " PACKAGES"
xsheet.Cells(39, 3) = "CIF DALIAN"
Range("B44:G44").Borders(xlDiagonalDown).LineStyle = xlNone
Range("B44:G44").Borders(xlDiagonalUp).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeLeft).LineStyle = xlNone
Range("B44:G44").Borders(xlEdgeTop).LineStyle = xlNone
With Range("B44:G44").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("B44:G44").Borders(xlEdgeRight).LineStyle = xlNone
Range("B44:G44").Borders(xlInsideVertical).LineStyle = xlNone
xsheet.PrintPreview
Set X = Nothing
Set xsheet = Nothing
Set xlbook = Nothing
#5
没看明白程序,但我觉得你少一条语句。 Range("某个单元格").Select