用VBA实现Excel打印

用VBA实现Excel打印,vba,excel,printing,Vba,Excel,Printing,我已经编写了一个宏来从Excel中的数据打印出一些标签。我已经对设置进行了微调,使打印机能够打印标签上的信息,并且工作正常,但是当我在网络中使用同一台打印机的另一台计算机上使用同一宏时,它会变得有点不正常。。。我的预测是,在不同的PC上有不同的默认设置。有没有办法使它们相同,或者在我的微调代码开始之前重置打印默认值 编辑: 代码: 你能提供你目前正在使用的代码吗?我已经准备好了代码。。。实际上唯一重要的是,边距设置为0,最高边距为0.767。。。虽然我想增加边距,但它应该解决我的问题,因为在我的

我已经编写了一个宏来从Excel中的数据打印出一些标签。我已经对设置进行了微调,使打印机能够打印标签上的信息,并且工作正常,但是当我在网络中使用同一台打印机的另一台计算机上使用同一宏时,它会变得有点不正常。。。我的预测是,在不同的PC上有不同的默认设置。有没有办法使它们相同,或者在我的微调代码开始之前重置打印默认值

编辑: 代码:


你能提供你目前正在使用的代码吗?我已经准备好了代码。。。实际上唯一重要的是,边距设置为0,最高边距为0.767。。。虽然我想增加边距,但它应该解决我的问题,因为在我的电脑上,它正常打印标签,但在另一台电脑上,文本太高了一点,有时它打印一个空标签(它认为它太高了,需要两个标签来打印全文?)
With ActiveSheet.PageSetup
    .LeftHeader = ""
    .CenterHeader = ""
    .RightHeader = ""
    .LeftFooter = ""
    .CenterFooter = ""
    .RightFooter = ""
    .LeftMargin = Application.InchesToPoints(0)
    .RightMargin = Application.InchesToPoints(0)
    .TopMargin = Application.InchesToPoints(0.767716535433071)
    .BottomMargin = Application.InchesToPoints(0)
    .HeaderMargin = Application.InchesToPoints(0)
    .FooterMargin = Application.InchesToPoints(0)
    .PrintHeadings = False
    .PrintGridlines = False
    .PrintComments = xlPrintNoComments
    .CenterHorizontally = True
    .CenterVertically = True
    .Orientation = xlPortrait
    .Draft = False
    .FirstPageNumber = xlAutomatic
    .Order = xlDownThenOver
    .BlackAndWhite = False
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    .PrintErrors = xlPrintErrorsDisplayed
    .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

Dim rngPrint As Range

Do While (delaj)
    If IsEmpty(Cells(i, "B")) Then
        delaj = False
        Exit Do
    End If

    If Cells(i + 5, "D") = True Then
        Range(Cells(i, "B"), Cells(i + 6, "C")).PrintOut
    End If
    i = i + 9
Loop