Solved

Print Preview of Excel worksheet in VB codes

Posted on 2002-03-07
3
500 Views
Last Modified: 2012-06-27
I was coding in VB, required to show a PRINT PREVIEW of an EXCEL worksheet , WITHOUT USERS ABLE TO CHANGE THE CONTENTS OF THE PREVIEW WORKSHEET, JUST LIKE MS OFFICE PRINT PREVIEW. How should I go about doing it? Without USING EXCEL OBJECTS. Thanks!
0
Comment
Question by:sunburnt
  • 3
3 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 6849502
Hi sunburnt,

This should solve your problem:

Private Sub Command1_Click()
    Dim iExcel As Excel.Application
    Dim iWBook As Workbook
    Dim iWSheet As Worksheet
    TempDBPath = "D:\Project\Icon\develop\DO.xls"
    Set iExcel = CreateObject("excel.application")
    iExcel.Visible = True
    Set iWBook = iExcel.Application.Workbooks.Open(TempDBPath)
    Set iWSheet = iWBook.Worksheets("gr")
    iWSheet.PrintPreview False
    'Set iWSheet = Nothing
    'iWBook.Close True
    'Set iWBook = Nothing
    'iExcel.Quit
    'Set iExcel = Nothing
End Sub

Cheers,
ryancys
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6849516
Ohya, make sure to add the M$ Excel 9.0 Object Library from References.
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6849537
> Without USING EXCEL OBJECTS
Sorry, Excel Object is required here..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now