Print excel sheet using VB6.5

i am looking for a script that in an active sheets selects the active range (all filled-in columns rows), in the page setup verifies if the  papersize is set on A3 if not message to user, set to fit 1page by xx tall and then printout.

Can anyone help me ?
LVL 3
SPARC-DESIGNAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rory ArchibaldCommented:
Something like:

With ActiveSheet.PageSetup
        If .PaperSize <> xlPaperA3 Then
            MsgBox "Paper is not A3"
        Else
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = False
            ActiveSheet.PrintOut
        End If
    End With

Open in new window

SPARC-DESIGNAuthor Commented:
Thx, I worked on your solution and finally came up with
 Although i am not sure where the macro detects the active range <
With ActiveSheet.PageSetup
    If .PaperSize = xlPaperA3 Then
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = False
            ActiveSheet.PrintOut
        Else
            If .PaperSize <> xlPaperA3 Then
          askquest = MsgBox("Papersize is not A3. Do you wish to continue printing?", vbYesNo + vbQuestion, "Warning!!!")
                 If askquest = vbYes Then
                    .Zoom = False
                    .FitToPagesWide = 1
                    .FitToPagesTall = False
                    ActiveSheet.PrintOut
                 Else
                    Cancel = False
                End If
            End If
    End If
End With
SPARC-DESIGNAuthor Commented:
Is there a way to change the paperzise to A3
like
if  .papersize <> xlpapersizeA3 then xlpapersizeA3
 
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Rory ArchibaldCommented:
if  .papersize <> xlpapersizeA3 then .papersize = xlpapersizeA3

By default Excel will just print the used range, so I didn't see the relevance of that?
SPARC-DESIGNAuthor Commented:
when i try this i get an error message :
Unable to set the papersizeproperty  of the pagesetupclass
 
here is the 'full'code

Sub PrintPage()
With ActiveSheet.PageSetup
    If .PaperSize = xlPaperA3 Then
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = False
            ActiveSheet.PrintOut
        Else
            If .PaperSize <> xlPaperA3 Then
          askquest = MsgBox("Papersize is not A3 and will be set to A3. Do you wish to continue printing?", vbYesNo + vbQuestion, "Warning!!!")
                 If askquest = vbYes Then
                    .PaperSize = xlpapersizeA3
                    .Zoom = False
                    .FitToPagesWide = 1
                    .FitToPagesTall = False
                    ActiveSheet.PrintOut
                 Else
                    Cancel = False
                End If
            End If
    End If
End With
End Sub
Rory ArchibaldCommented:
Sorry I just copied the constant you had posted - it's actually xlPaperA3 not xlpapersizea3- so:
If .PaperSize <> xlPaperA3 Then .PaperSize <> xlPaperA3
SPARC-DESIGNAuthor Commented:
Thx RORVA, i just changed  > papersize = xlPaperA3  and this does the trick>
Thx for the quick and good support

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rory ArchibaldCommented:
You're welcome!
FYI, you can simply accept an answer rather than requesting the close process.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.