Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Print preview makes shapes vanish

  1. #1
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Print preview makes shapes vanish

    I have a very strange problem. I have a macro that does a print preview of various sheets. The problem is that when I run this macro all shapes on that sheet vanish and don't come back.

    It does not occur on most pc's. I have tested on Windows 7 & Office 2007, Vista & Office 2007 and on many different PC's.

    However on XP & Office 2007 the problem occurs. I am not sure if it is relevant, but I am using activeX 2.6 (for some forms work elsewhere, not sure if this has any relevance to Print Preview)

    I though that there may be some security macro's running in personal.XLSB but that is not the case. It is just blank. Infact it did not exist until I created it with a blank macro.

    I have added some code after the print preview to check for any shapes and make them visible but that does not seem to help either. Here is the code

     With ActiveSheet.PageSetup
            .LeftFooter = PrintedPageDescription
            .CenterFooter = Format(Now(), "dd mmm yyyy")
            .RightFooter = "Page &P"
            .OddAndEvenPagesHeaderFooter = False
            .DifferentFirstPageHeaderFooter = False
            .ScaleWithDocHeaderFooter = True
            .AlignMarginsHeaderFooter = True
         End With
      
        ActiveWindow.SelectedSheets.PrintPreview
         
        For Each sh In ActiveSheet.Shapes
            sh.Visible = True
        Next sh
    Any help would be much appreciated.

  2. #2
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    Slight Update,

    I wrote some test code to note down any shapes that existed after the print preview. Seems they are still there, but they are hidden. But WHY!!!!! grr even less hair left now.

  3. #3
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: Print preview makes shapes vanish

    Have you set the shapes not to print?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  4. #4
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Print preview makes shapes vanish

    To add to Roy's remark:

    Sub Roy_vba()
      ActiveWorkbook.DisplayDrawingObjects = xlAll
    End Sub



  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Print preview makes shapes vanish

    1. Do you have SP2 installed?
    2. Have you tried a different printer?
    3. Have you checked to see if the shapes have been set to 0 width and/or height?

  6. #6
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    Thanks for your replies.

    Sadly I am working remotely and with a company whose IT department is not overly helpful so I cannot change printer and don't know if SP2 is installed. Do you know if some relevance to SP2. I would hope they did have SP2 installed as it fixed a lot of XP issues.

    No I have not checked their size, only their X& Y positions which do not change (left,top) and the fact they are of type 1 (rectangles - I use for macros)

    @Roy
    I have this code surrounding the print.

    Before-

       For Each sh In ActiveSheet.Shapes
            If sh.Type = 1 Then sh.Visible = False      'rectangles
        Next sh
    And after
       For Each sh In ActiveSheet.Shapes
            If sh.Type = 1 Then sh.Visible = True      'rectangles
        Next sh
    @snb
    ActiveWorkbook.DisplayDrawingObjects = xlAll

    is that a replacement. I guess that is to re-enable them to hide them do I used
    xlHide?

  7. #7
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    Ah just remembered another point.

    The reason I cycle through all shapes is that there are Graphs, which I believe are also classed as shapes when hiding. That is why I check their type to be 1, which I believe is rectangles.

    Also it seems to do the same thing if they use print preview on the menubar(top of screen)

    Yet if you start from scratch create a new sheet, add a shape and do print preview then quit Print Preview it does not loose the shape.

  8. #8
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Print preview makes shapes vanish

    shape.type =1 stands for msoAutoShape

    So that's more than just a rectangle.



  9. #9
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    Just tried a different method by setting each buttons .printobject property to false. Fingers crossed and thanks for the ideas so far.

  10. #10
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    Well my latest version did not work either. Now I am not disabling any shapes at all and I just set the property of each shape (print object) to false manually in Excel. Works lovely on my machine (Windows7 with XP) still, but on the XP machine with Excel 2007 for some reason it hides all shapes when coming back from a print preview. There is nothing in my code now that does this!! My print routine now, in its entirity is:-

    Sub printing()
        
        Dim PrintingArea As String
        Dim x As Integer
        
        Application.EnableEvents = False           
     
        If Left(PrintedPageDescription, 3) = "Rem" Then             'We need to create print area of Remedials page.
            x = 8
            While Cells(x, 1) <> ""
                x = x + 1
            Wend
            PrintingArea = "$A$1:$G$" + Trim(Str(x))
            ActiveSheet.PageSetup.PrintArea = PrintingArea
        End If
     
        With ActiveSheet.PageSetup
            .LeftFooter = PrintedPageDescription
            .CenterFooter = Format(Now(), "dd mmm yyyy")
            .RightFooter = "Page &P"
            .OddAndEvenPagesHeaderFooter = False
            .DifferentFirstPageHeaderFooter = False
            .ScaleWithDocHeaderFooter = True
            .AlignMarginsHeaderFooter = True
         End With
      
        ActiveSheet.PrintPreview EnableChanges:=False
        
        Application.EnableEvents = True          
    End Sub
    Again any help would be useful

  11. #11
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    Anybody got any ideas on this. The company I am doing it for has a big presentation today and I am purplexed. Seems the shapes still exist as you can still call the macro that the rectangles have assigned to them. But they are not showing. I have also tried to force them back into view again by re-setting the visible property to true. Completely baffled. How else can they be hidden?

    Help would be very much appreciated.,

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Print preview makes shapes vanish

    As I mentioned earlier, you need to check their width and height - if either is 0, they would not be visible.

  13. #13
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Print preview makes shapes vanish

    You can 'refresh' the sheet using:

    For each sh in sheets(1).shapes
      sh.select
    next



  14. #14
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    @RomperStomper - Yeah I wrote a macro to e-mail me all the data for the shapes and all seems to be in order! Which is why it is so odd. Shame you can't trap an event after printing.

    @snb - I will give that a shot. Thanks.

  15. #15
    Registered User
    Join Date
    06-13-2011
    Location
    Neston, England
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    29

    Re: Print preview makes shapes vanish

    Just got some more information back and the visibilty flag is set in all of the shapes yet they are still invisible. Their position and size are as they should be. Here is the output, yet this shape is not visible :-

    Name: Rectangle 3
    Type: 1
    Xpos: 482.4
    Ypos: 4.8
    Height: 28.34646
    Width: 55.19291
    Visibility: -1
    On Action: 'A - Compliance Tracker Master - E.xlsm'!Home
    Placement: 1
    Control Format - Print Object: False
    -------------------------------------------------------------------------
    Name: Rectangle 4
    Type: 1
    Xpos: 420.9
    Ypos: 4.2
    Height: 28.34646
    Width: 55.19291
    Visibility: -1
    On Action: 'A - Compliance Tracker Master - E.xlsm'!printing
    Placement: 1
    Control Format - Print Object: False

    snb - The refreshing didn't work either. But thinking about it nor did going to another page and back again, which I guess would have 'refreshed' them all anyway.

    Does anybody know what 'Resource' shapes come under. i.e. is it possible their is a missing OCX file. Or if there is any dll or whatever used for print preview.

    Also somebody else mentioned the Killbit issue, but that seems to stop them from appearing in the first place. These buttons appear and work fine flying all around the sheets. There are 20 sheets and navigation around the sheet is via macro buttons and all have a home to main menu. They all work and function fine until they call print preview. Then on return the shapes have vanished!

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0