none
Cant programmatically print excel worksheet when a .pdf file is embadded in the worksheet. RRS feed

  • Question

  • Hi,

    I am using Visual Studio Pro for daveloping controlled enviornment for excell workbooks.

    I am programmatically opening .xlsx file and printing it using following function call

                                try
                                {
                                    xlWorkbook_original.PrintOutEx(COMUtils.MissingValue  // from page
                                                                        , COMUtils.MissingValue  // to page
                                                                        , 1         // copies
                                                                        , COMUtils.MissingValue // preview
                                                                        , COMUtils.MissingValue // active printer
                                                                        , COMUtils.MissingValue // print to file
                                                                        , COMUtils.MissingValue  // collate
                                                                        , COMUtils.MissingValue // print to file name
                                                                        , false                 // ignore print areas
                                                                        );
                                    
                                }
                                catch (Exception ex)
                                {

    }

    For normal excel file, it works fine, but if a pdf file is embeded in worksheet, nothing appears on printer.

    When observed in debugger mode, the execution doesnt go in the catch block . Means the print function gets executed without any exception.

    What can be the reason ?

    Thanks.

    Mukund Gadre.

    Tuesday, June 16, 2015 10:56 AM

Answers

  • Hello Mukund,

    Try to use the macro recorder available in Excel for generating the required code in the background. See Create or delete a macro for more information about the Macro recorder. Just do the steps you need run programmatically while the recorder is on. Do you get the same method call in VBA? Is the file printed correctly in that case?


    Tuesday, June 16, 2015 12:47 PM

All replies

  • Hello Mukund,

    Try to use the macro recorder available in Excel for generating the required code in the background. See Create or delete a macro for more information about the Macro recorder. Just do the steps you need run programmatically while the recorder is on. Do you get the same method call in VBA? Is the file printed correctly in that case?


    Tuesday, June 16, 2015 12:47 PM
  • Hi Mukund,

    Base on my test in VS 2013 with Excel 2013, it works fine. (I tried to print to OneNote: Send to OneNote2013)

    I would like to know:

    1. What’s the result if you print it manually?
    2. What’s the result if you use other printer to print it?

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 17, 2015 6:01 AM
    Moderator
  • Thanks Eugene Astafiev for responding,

    but I am not using macro.

    I am daveloping C# solution. 

    Wednesday, June 17, 2015 6:15 AM
  • Hi Mukund,

    For the VSTO solution, it uses the excel object model too (the same as macro), just through PIA.

    I would like to know:

    • What’s the result if you print it manually?
    • What’s the result if you use other printer to print it?

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, June 18, 2015 2:12 AM
    Moderator
  • Thanks Eugene.

    Your idea of using Macro Recorder helped to solve the problem.

    Monday, July 13, 2015 9:36 AM