2017-12-19 10 views
0

항상 저의 답변을 여기에서 발견 했으므로 저의 천재가 저를 위해 또 하나의 트릭을 만들 수 있기를 바랍니다. 여기 상황이 있습니다. 몇 년 전 Excel 2016에서 작은 응용 프로그램을 만들었습니다. 이제 2 년 동안 완벽하게 운영되었습니다. 나는 그것이 나의 이전 직업에 있었다라고 말해야한다 (그러나 나는 아직도 여기의 판매 서비스 후의 종류를한다. ..). 어쨌든 요즘 그들은 Office 365로 이동 한 다음 kaboom으로 이동했습니다. 보고서를 인쇄하는 기능을 사용할 수 없습니다. 오류는 객체 '_Application'의Excel VBA Application.PrintCommunication이 네트워크 프린터로 더 이상 작동하지 않습니다.

런타임 오류 1004 방법 'PrintCommunication'이다

들이 사무실로 전환하기 전에 365 모든 것이 잘 작동 것을 기억하지 못했습니다.
또한 로컬 프린터 (USB 케이블로 연결)를 사용하는 경우 이전과 마찬가지로 완벽하게 작동한다는 점을 알아야합니다. 이 방법 (로컬 프린터)은 2 대의 컴퓨터에서 테스트되었으며 정상적으로 작동합니다. 그러나 회사의 네트워크 프린터라면 작동하지 않습니다.

편집 : 방금 회사의 일부에서 작동하며 하나가 아닌 것으로 밝혀졌습니다. 예를 들어, 모든 주 (캐나다의 주 : 미국은 미국의 주와 같음)의 직원을 제외하고는 모든 직원이 잘 작동합니다. 따라서 서버의 매개 변수 또는 이와 유사한 매개 변수와 호환되지 않는 무언가가 있어야합니다. 누군가를 도울 수 있습니까? 편집 끝

여기 저기 다른 사이트를 둘러 보았습니다. 나는 "print quality = 600"과 같은 다른 것들을 주석으로 처리하는 것에 대한 모든 트릭을 시도했다.

다음은 코드입니다. 오류는 라인에

Application.PrintCommunication = True 

"End Sub" 전에 4 라인입니다. 다른 라인 나는 오류가

Sub imprime_feuille_identification(trois_feuille) 
' 
    Sheets("IDENTIFICATION").Activate 
    ActiveWorkbook.Worksheets("MOYENS_CONTROLE").Cells(9, 16384) = ActiveSheet.Name    'identifie de quelle feuille vient la demande d'impression sert à y revenir ensuite 
    ActiveWorkbook.Worksheets("MOYENS_CONTROLE").Cells(10, 16384) = ""       'va servir à identifier qu'on veut imprimer une seule feuille 
    Range("A1:P38").Select 
    ActiveSheet.PageSetup.PrintArea = "$A$1:$P$38"            'définition de la zone d'impression 
    Application.PrintCommunication = False 
    With ActiveSheet.PageSetup 
     .PrintTitleRows = "$2:$2" 
     .PrintTitleColumns = "" 
    End With 
    Application.PrintCommunication = True 
    ActiveSheet.PageSetup.PrintArea = "$A$1:$P$38" 
    Application.PrintCommunication = False 
    With ActiveSheet.PageSetup 
     .LeftHeader = "" 
     .CenterHeader = "" 
     .RightHeader = "" 
     .LeftFooter = "" 
     .CenterFooter = "" 
     .RightFooter = " &9&P de &N " 
     .LeftMargin = Application.InchesToPoints(9.84251968503937E-02) 
     .RightMargin = Application.InchesToPoints(9.84251968503937E-02) 
     .TopMargin = Application.InchesToPoints(9.84251968503937E-02) 
     .BottomMargin = Application.InchesToPoints(9.84251968503937E-02) 
     .HeaderMargin = Application.InchesToPoints(0.196850393700787) 
     .FooterMargin = Application.InchesToPoints(0.196850393700787) 
     .PrintHeadings = False 
     .PrintGridlines = False 
     '.PrintComments = xlPrintNoComments 
     '.PrintComments = False 'xlPrintNoComments 
     .PrintQuality = 600    'Tried to comment out this line: still get the error 
     .CenterHorizontally = False 
     .CenterVertically = False 
     .Orientation = xlLandscape 
     .Draft = False 
     .PaperSize = xlPaperLetter 
     .FirstPageNumber = xlAutomatic 
     .Order = xlDownThenOver 
     .BlackAndWhite = False 
     .Zoom = False 
     .FitToPagesWide = 1 
     .FitToPagesTall = 0 
     .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 
    Application.PrintCommunication = True  'THE ERROR HAPPENS HERE' 

    If trois_feuille <> 1 Then     'si le sub a été appelé en dehors du sub "imprime trois feuille" alors on fait 
     Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")         'affiche la page d'impression 
    End If  
End Sub 

그래서 누구든지, 어떤 밝은 아이디어와 해결책이 없다 .printCommunication = True 전환? 문제에 대한 나의 설명이 명확하지 않은 경우에는 정확성을 요청하는 것을 주저하지 마십시오.

대단히 감사합니다.

오류는 광고에 기인되는

답변

1

.Zoom = False 

VBA 통해 줌 속성을 설정하는 경우 (10), 400 (예, .Zoom = 25)를 제어하고 싶은 경우 스케일링 사이 .Zoom가 = 정수 값으로 설정해야 줌 방법을 사용합니다. 이 값은 Excel (예 : 10 % ~ 400 %)에 의해 백분율로 변환 된 다음 승수로 사용됩니다.

너비가 크고 페이지 수를 제어하려면 .FitToPagesWide = some Integer.FitToPagesTall = some Integer 속성을 사용하십시오.

.FitTo... properties을 사용하는 경우 .Zoom은 Excel에서 VBA 코드가 아닌 false로 설정됩니다. 다음은 MS 문서에 대한 링크로 .Zoom 속성의 사용법을 설명합니다.

그래서 당신은 제거하거나 .Zoom = False 행 또는 프린터 사용이 USB 케이블을 통해 연결되어있는 경우 왜 그것을 잘 작동

.FitToPagesWide = 1 
.FitToPagesTall = 0 
+0

그러나 두 줄 중 하나를 주석 처리해야합니다? 누군가 그 제안에 동의합니까? 또한 문제없이 2 년간 일했음을 기억하십시오. – excelguigui11

+0

나는 더 많이 파 냈다. 나는 또한'.PrintQuality = 600' 라인이 아마도 몇몇 문제를 일으키고 있음을 발견했다. USB 프린터는 600dpi의 구성을 지원할 수 있습니다. 네트워크 프린터는 "고품질"과 같은 기능을 제공 할 수 있습니다. 이는 내가 가지고있는 프린터에서 테스트 한 것입니다. 네트워크 프린터에서'.PrinterQuality = 600'을 설정하면 600dpi 설정을 지원하지 않기 때문에 오류가 발생합니다. [MSDN] (https://msdn.microsoft.com/en-us/vba/excel-vba/articles/pagesetup-printquality-property-excel)에는 PrintQuality가 프린터 드라이버에 따라 오류를 유발할 수 있다고 나와 있습니다. –

+0

PrintQuality 설정이 오류가 발생하는 위치이면 프린터와의 통신이 꺼져있는 동안에는 발생하지 않습니다. 내가했던 추가 연구에서 인터넷에이 문제에 대한 수많은 질문/답변이 있습니다. StackOverFlow에 대한 많은 질문/답변이 여기에 있습니다. 또한 새 프린터 드라이버가 포함되어있을 수있는 Office 365에 대한 업데이트가있을 때까지 작업했을 수도 있습니다. –