[Excel] print preview problem-VBForums
Results 1 to 13 of 13

Thread: [Excel] print preview problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    6

    [Excel] print preview problem

    Hi Guys...

    I am new to this thread as i am new to vb programming.

    now, the problem is that in my application i m generating sql database. the data is displayed in datagridview. the user has a facility to filter data according to certain parameters. once filtered, user should be able print or perview the data. for the printing purpose i m writing the filtered data to excel sheet which is displayed in another tab. from here he can give print or printpreview command.

    catch : when the user clicks print command, every thing works fine. i.e. print dialog comes up and on ok sheet gets printed. but when user issues print preview command, nothing nothing happens. preview window doesnt shows up.

    what could be the problem or is there any other way to do this?

    any help or suggestions will be highly appreciated.

  2. #2
    Addicted Member Smartacus's Avatar
    Join Date
    Oct 2009
    Location
    Deep South, USA
    Posts
    190

    Re: [Excel] print preview problem

    Please supply the version of VBA/Office and the code you are using on your Preview button
    ***************************************************
    Smartacus comes packaged "As Is With No Warranty"

    ************* Useful Links ******************
    FAQs: Index / Database Development / .NET CodeBank / Before Posting Here...MSDN

    MZTools (I love this tool when using VB6 - Free) /

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    6

    Re: [Excel] print preview problem

    thnks for ur reply Smartacus

    version : vb express 2008, office : 2003

    Private Sub PrintPreviewToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
    'Me.TabControl1.SelectTab(1)
    If Not Populated Then Populate_Data()
    PPrv = True
    If Not Loaded Then
    LoadBrowser()
    Else
    PPrv = False
    WB2.ShowPrintPreviewDialog()
    End If
    End Sub

    it first checks whether excel sheet is generated and data is written in it. if not does it and then loads that xl sheet in webbrowser and preview dialog is called in another routine but is exactly as is here. if already populated and loaded by some other routine then show print preview dialog.

    note: print dialog is also used in exactly same way. it works perfect but preview doesnt. cant figure out whats the difference between them as both are webbrowser commands.

    please suggest some solution.

    thnks again.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,918

    Re: [Excel] print preview problem

    and we all thought the preview button was in excel!!!!!!!
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    6

    Re: [Excel] print preview problem

    any solutions, suggestions please ?

  6. #6
    Lively Member tarius222000's Avatar
    Join Date
    Jul 2005
    Location
    Jacksonville, FL
    Posts
    80

    Lightbulb Re: [Excel] print preview problem

    I don't know if this will help, but if you can do the following within the application (and there is something to print) it should work.

    Code:
    ActiveWindow.SelectedSheets.PrintPreview
    this is the VBA code and I have absolutely no experience when it comes to linking .net (orVB6) to an application, but hopefully this helps
    Last edited by tarius222000; Mar 24th, 2010 at 12:00 AM. Reason: sp

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,918

    Re: [Excel] print preview problem

    can you do it manually in your webbrowser?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    6

    Re: [Excel] print preview problem

    Quote Originally Posted by tarius222000 View Post
    I don't know if this will help, but if you can do the following within the application (and there is something to print) it should work.

    Code:
    ActiveWindow.SelectedSheets.PrintPreview
    this is the VBA code and I have absolutely no experience when it comes to linking .net (orVB6) to an application, but hopefully this helps
    i have tried it with no luck.

    isn't there any other way pleaseeeeeeeeeeeeeeeee.

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    19,918

    Re: [Excel] print preview problem

    this really .net programming, maybe better to get answer in vb.net forum

    pm a mod to move if appropriate
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    6

    Re: [Excel] print preview problem

    Quote Originally Posted by westconn1 View Post
    this really .net programming, maybe better to get answer in vb.net forum

    pm a mod to move if appropriate
    ok. thanks to all for ur replies. i m moving to vb.net forums.

    chenz

  11. #11
    Addicted Member Smartacus's Avatar
    Join Date
    Oct 2009
    Location
    Deep South, USA
    Posts
    190

    Re: [Excel] print preview problem

    Chenz, If you are starting a new post in VB.Net, be sure to specify the version VB Express and Office version.

    Post your code that is firing the print preview to get the fastest response. If there is no info, many will move on to help those who are more detailed. Details, Details, Details!
    ***************************************************
    Smartacus comes packaged "As Is With No Warranty"

    ************* Useful Links ******************
    FAQs: Index / Database Development / .NET CodeBank / Before Posting Here...MSDN

    MZTools (I love this tool when using VB6 - Free) /

  12. #12

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    6

    Re: [Excel] print preview problem

    hi guys ...

    i m back here because i didnt get any response on vb dot net forums. not a single reply.

    i think we guys will have to solve it over here itself

    ok, now. what should i do next.

    please guide me. i m totally lost.

    chenz

  13. #13
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,928

    Re: [Excel] print preview problem

    Chenz, Can you answer Pete's question in Post # 7
    The poster formerly known as koolsid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.