2017-12-19 250 views
0

私はいつもここで私の答えを見つけたので、あなたの天才のうちの1人が私のためにもう1つのトリックを引き出すことを願っています。ここに状況があります。 私は2、3年前にExcel 2016で小さなアプリケーションを作成しました。今は2年間は完璧に動いています。私はそれが私の以前の仕事であったと言わなければなりません(しかし、私はまだここで販売サービスをしています...)。とにかく、最近彼らはOffice 365に移動し、その後kaboom!作成したレポートを印刷する機能は使用できません。 エラーは、オブジェクト のExcel VBA Application.PrintCommunicationがネットワークプリンタでもう機能しない

実行時エラー1004メソッド「PrintCommunication」「_Applicationは」彼らはオフィス365に切り替える前に、すべてが正常に働いていたことを覚えておいてください

を失敗しています。
また、(USBケーブルで接続された)ローカルプリンタを使用する場合は、以前と同様に完全に動作することを知っておく必要があります。この方法(ローカルプリンタ)は2台のコンピュータでテストされ、正常に動作します。しかし、それが会社のネットワークプリンタであれば動作しません。

編集:私は、それが会社のある部分ではなく、1つではないことを知りました。たとえば、すべての州の従業員(カナダの州:州は米国の州に相当)は例外で、それ以外は正常に機能します。したがって、サーバー上のパラメーターまたはそのようなパラメーターと互換性のないものがなければなりません。それは誰かを助けるか? 編集終了

私はここや他のサイトを見回しました。私は、 "print quality = 600"やそのようなもののような行を "コメントアウト"することに関するすべてのトリックを試しました。

以下はコードです。エラーがラインに"End Sub"

Application.PrintCommunication = True 

4行です。他のライン、私は.printCommunication = Trueを切り替える際に誤りが

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 

だから、誰も、任意の鮮やかなアイデアや解決策はありませんか?私の問題の説明が明確でない場合は、躊躇しないでください。

ありがとうございます。

答えて

1

エラーがVBA経由ズームプロパティを設定するときは、スケーリングを制御したい場合は、あなたが10と400(例えば、.Zoom = 25)の間.Zoom =整数値を設定する必要がありますライン

.Zoom = False 

によって引き起こされていますズーム方法を使用してその値は、Excel(例えば、10%〜400%)によってパーセンテージに変換され、次に乗数として使用される。

ページ幅と高さを制御する場合は、プロパティ.FitToPagesWide = some Integer.FitToPagesTall = some Integerを使用します。

.FitTo... propertiesを使用する場合、.ZoomはVBAコードではなくExcelでfalseに設定されます。ここには、.Zoomプロパティの使用方法を説明するMSドキュメントへのリンクがあります。

だから.Zoom = False行または2行

.FitToPagesWide = 1 
.FitToPagesTall = 0 
+0

のいずれかを削除するかコメントアウトする必要があります。しかし、プリンタの使用はUSBケーブルを介して接続されているならば、なぜそれが正常に動作していますか?他の誰かがその提案に同意しますか?また、問題なく2年間働いたことを覚えておいてください。 – excelguigui11

+0

もう少し掘り下げました。また、 '.PrintQuality = 600'という行もおそらく問題を引き起こしていることがわかりました。 USBプリンタは600dpiの設定をサポートしていますが、ネットワークプリンタには「高品質」のようなものがあります。これは私が持っているプリンタでテストしたものです。ネットワークプリンタで '.PrinterQuality = 600'を設定した場合、600 dpiの設定をサポートしていないのでエラーが出ます。 [MSDN](https://msdn.microsoft.com/en-us/vba/excel-vba/articles/pagesetup-printquality-property-excel)には、PrintQualityによってプリンタドライバによってエラーが発生することがあります。 –

+0

PrintQuality設定がエラーの発生場所である場合、プリンタとの通信がオフの間は発生しません。私が行った追加の研究から、インターネット上のこの問題に対する多くの質問/回答があります。ここではStackOverFlowに関する多くの質問/回答があります。また、新しいプリンタドライバを含む可能性のあるOffice 365のアップデートまでは機能していた可能性があります。 –

関連する問題