Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Little Question

Little Question

Scheduled Pinned Locked Moved C / C++ / MFC
questiontestingtoolstutorial
11 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ankush Mehta
    wrote on last edited by
    #1

    :-OHi all, Please tell whether we can use ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE); to print 1) Text(*.txt) file 2) Document file 3) Excel Sheet 4) Access table 5) Powerpoint Slide 6) Webpages 7) Images Jpg,jpeg,bmp etc. I am asking this because i used automation to achieve printing for most of these. As an afterthought, it came perhaps i could have done it using ShellExecute also.Am i right in thinking so?i don't know. u know.... then plz tell because if that happens it will make my application really simple & fast without any overhead. Please Guide. Regards, Ankush Mehta

    S 1 Reply Last reply
    0
    • A Ankush Mehta

      :-OHi all, Please tell whether we can use ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE); to print 1) Text(*.txt) file 2) Document file 3) Excel Sheet 4) Access table 5) Powerpoint Slide 6) Webpages 7) Images Jpg,jpeg,bmp etc. I am asking this because i used automation to achieve printing for most of these. As an afterthought, it came perhaps i could have done it using ShellExecute also.Am i right in thinking so?i don't know. u know.... then plz tell because if that happens it will make my application really simple & fast without any overhead. Please Guide. Regards, Ankush Mehta

      S Offline
      S Offline
      S Douglas
      wrote on last edited by
      #2

      Ankush Mehta wrote:

      1. Text(*.txt) file 2) Document file 3) Excel Sheet 4) Access table 5) Powerpoint Slide 6) Webpages 7) Images Jpg,jpeg,bmp etc.

      Try it, if it doenst work then you will need to find another method. :) 1: Should work 2: Should work 3:Should work 4: Nope, will need to find another method, I would dump it to an excel file and then print that. 5: Nope wont work, have no idea never really worked with power point. 6: Should work. 7: Dont know.


      ZeePain! wrote:

      This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

      thedailywtf.com[^]

      A 1 Reply Last reply
      0
      • S S Douglas

        Ankush Mehta wrote:

        1. Text(*.txt) file 2) Document file 3) Excel Sheet 4) Access table 5) Powerpoint Slide 6) Webpages 7) Images Jpg,jpeg,bmp etc.

        Try it, if it doenst work then you will need to find another method. :) 1: Should work 2: Should work 3:Should work 4: Nope, will need to find another method, I would dump it to an excel file and then print that. 5: Nope wont work, have no idea never really worked with power point. 6: Should work. 7: Dont know.


        ZeePain! wrote:

        This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

        thedailywtf.com[^]

        A Offline
        A Offline
        Ankush Mehta
        wrote on last edited by
        #3

        thanks sfdougl, 1) Agree 2) Agree 3) Agree 4) Agree,automation is the option in my case because i want to enumerate tables in the database programmatically & then proceed towards printing.i think i am right.plz tell if u have other option to enlist tables in database. 5) it doesn't work in my case 6)I could not manage printing a webpage with ShellExecute.My code is like this: ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE); 7)Prints only bmp.I changed extension to bmp, printed & renamed filename to original extension Please tell me about point 6) after trying it out.Also tell me about point 4) if you have something to tell about it. Regards, Ankush Mehta

        S 1 Reply Last reply
        0
        • A Ankush Mehta

          thanks sfdougl, 1) Agree 2) Agree 3) Agree 4) Agree,automation is the option in my case because i want to enumerate tables in the database programmatically & then proceed towards printing.i think i am right.plz tell if u have other option to enlist tables in database. 5) it doesn't work in my case 6)I could not manage printing a webpage with ShellExecute.My code is like this: ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE); 7)Prints only bmp.I changed extension to bmp, printed & renamed filename to original extension Please tell me about point 6) after trying it out.Also tell me about point 4) if you have something to tell about it. Regards, Ankush Mehta

          S Offline
          S Offline
          S Douglas
          wrote on last edited by
          #4

          Ankush Mehta wrote:

          1. if you have something to tell about it.

          Here is a good quick way to dump a recordset to a excel file, then call shellexecute to print that file. Delete it it after your done. CString str; str.Format("SELECT * INTO [Excel 8.0;DATABASE=%s].[%s] FROM [%s]", ExcelFile, Worksheet, table); Create an ADO Connection object to the database then call. pConn->Execute(str.AllocSysString(), NULL, adExecuteNoRecords); To enumerate the tables in an access database try SELECT MSysObjects.Type, MSysObjects.Name FROM MSysObjects WHERE MSysObjects.Type=1;

          Ankush Mehta wrote:

          6)I could not manage printing a webpage with ShellExecute.My code is like this: ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE);

          Try ShellExecute("explorer.exe","print",m_FileName,NULL,NULL,SW_HIDE);


          ZeePain! wrote:

          This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

          thedailywtf.com[^]

          A 1 Reply Last reply
          0
          • S S Douglas

            Ankush Mehta wrote:

            1. if you have something to tell about it.

            Here is a good quick way to dump a recordset to a excel file, then call shellexecute to print that file. Delete it it after your done. CString str; str.Format("SELECT * INTO [Excel 8.0;DATABASE=%s].[%s] FROM [%s]", ExcelFile, Worksheet, table); Create an ADO Connection object to the database then call. pConn->Execute(str.AllocSysString(), NULL, adExecuteNoRecords); To enumerate the tables in an access database try SELECT MSysObjects.Type, MSysObjects.Name FROM MSysObjects WHERE MSysObjects.Type=1;

            Ankush Mehta wrote:

            6)I could not manage printing a webpage with ShellExecute.My code is like this: ShellExecute(NULL,"print",m_FileName,NULL,NULL,SW_HIDE);

            Try ShellExecute("explorer.exe","print",m_FileName,NULL,NULL,SW_HIDE);


            ZeePain! wrote:

            This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

            thedailywtf.com[^]

            A Offline
            A Offline
            Ankush Mehta
            wrote on last edited by
            #5

            when i use the copy-paste code line given by you following error is generated.i am using VC++ 6.0. cannot convert parameter 1 from 'char [13]' to 'struct HWND__ *':( Regards, Ankush Mehta

            S 1 Reply Last reply
            0
            • A Ankush Mehta

              when i use the copy-paste code line given by you following error is generated.i am using VC++ 6.0. cannot convert parameter 1 from 'char [13]' to 'struct HWND__ *':( Regards, Ankush Mehta

              S Offline
              S Offline
              S Douglas
              wrote on last edited by
              #6

              :-O Opps, I wasnt paying attention. Lets see now how did I do it (FYI, Im no where near my dev computer and cant verify this at all so its based off memory, and I often have corrupt memory errors) ShellExecute(NULL, "print", "explorer.exe", m_FileName, NULL, SW_HIDE); Or combine both explorer and file name CString str = _T("explorer.exe "); str += m_FileName; ShellExecute(NULL, "print", str, NULL, NULL, SW_HIDE); Hows that?


              ZeePain! wrote:

              This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

              thedailywtf.com[^] -- modified at 4:34 Thursday 8th December, 2005

              A 1 Reply Last reply
              0
              • S S Douglas

                :-O Opps, I wasnt paying attention. Lets see now how did I do it (FYI, Im no where near my dev computer and cant verify this at all so its based off memory, and I often have corrupt memory errors) ShellExecute(NULL, "print", "explorer.exe", m_FileName, NULL, SW_HIDE); Or combine both explorer and file name CString str = _T("explorer.exe "); str += m_FileName; ShellExecute(NULL, "print", str, NULL, NULL, SW_HIDE); Hows that?


                ZeePain! wrote:

                This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                thedailywtf.com[^] -- modified at 4:34 Thursday 8th December, 2005

                A Offline
                A Offline
                Ankush Mehta
                wrote on last edited by
                #7

                No errors, But no output also just as with the first shell execute statement i sent:doh:... Ankush Mehta

                S 2 Replies Last reply
                0
                • A Ankush Mehta

                  No errors, But no output also just as with the first shell execute statement i sent:doh:... Ankush Mehta

                  S Offline
                  S Offline
                  S Douglas
                  wrote on last edited by
                  #8

                  Your going to make me work arent yea? :) As I said Im not near a computer with VS installed, but I do have MS Word and VBA. This just printed the file. ShellExecute(0, "print", "C:\workorder.html", 0, 0, 3) One more thing, ShellExecute returns a HINSTANCE, which can be cast to an int. What is the return? Is should be a value higher than 32. Google Cache of a website with the error return codes[^] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp[^]


                  ZeePain! wrote:

                  This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                  thedailywtf.com[^] -- modified at 6:22 Thursday 8th December, 2005

                  A 1 Reply Last reply
                  0
                  • S S Douglas

                    Your going to make me work arent yea? :) As I said Im not near a computer with VS installed, but I do have MS Word and VBA. This just printed the file. ShellExecute(0, "print", "C:\workorder.html", 0, 0, 3) One more thing, ShellExecute returns a HINSTANCE, which can be cast to an int. What is the return? Is should be a value higher than 32. Google Cache of a website with the error return codes[^] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp[^]


                    ZeePain! wrote:

                    This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                    thedailywtf.com[^] -- modified at 6:22 Thursday 8th December, 2005

                    A Offline
                    A Offline
                    Ankush Mehta
                    wrote on last edited by
                    #9

                    well, one last question how to typecast to int......plz answer this one sfdougl...:) Ankush Mehta

                    S 1 Reply Last reply
                    0
                    • A Ankush Mehta

                      well, one last question how to typecast to int......plz answer this one sfdougl...:) Ankush Mehta

                      S Offline
                      S Offline
                      S Douglas
                      wrote on last edited by
                      #10

                      Ankush Mehta wrote:

                      well, one last question how to typecast to int

                      Sure you could do the following, HINSTANCE hresult = ShellExecute(params) TRACE("Result of Print %d\n", (int)hresult);


                      ZeePain! wrote:

                      This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                      thedailywtf.com[^]

                      1 Reply Last reply
                      0
                      • A Ankush Mehta

                        No errors, But no output also just as with the first shell execute statement i sent:doh:... Ankush Mehta

                        S Offline
                        S Offline
                        S Douglas
                        wrote on last edited by
                        #11

                        I just tested the following and it works in VS6. HINSTANCE handle = ShellExecute(0, "print", "C:\\WorkOrder.html", NULL, NULL, SW_SHOW ); The only down side that I see here is it prompts the user with the printer settings dialog. All they have to do is click print but still...


                        ZeePain! wrote:

                        This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.

                        thedailywtf.com[^] -- modified at 10:00 Thursday 8th December, 2005

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups