Solved

Print Preview of Excel worksheet in VB codes

Posted on 2002-03-07
3
498 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
Comment Utility
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
Comment Utility
Ohya, make sure to add the M$ Excel 9.0 Object Library from References.
0
 
LVL 49

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

9 Experts available now in Live!

Get 1:1 Help Now