Solved

VB and Excel

Posted on 2002-06-27
6
214 Views
Last Modified: 2010-05-02
Hi,

I am calling an excel template from my vb app. and printing the excel sheet as follows.

xl.ActiveSheet.PrintOut

xl is excel object and everything is working fine with this statement, but I need to display the print dialog box to the user, so that the user can specifiy number of copies, paper settings, etc.

How do I display print dialog box?

Thanks for any ideas.

Chandu

0
Comment
Question by:chandukb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 100 total points
ID: 7115041
Hi chandukb,

-found a snippet on the net

Private Sub cmdQPrint_Click()
   Dim intBegin As Integer, intEnd As Integer
   Dim intNumCopies As Integer, intI As Integer
   Dim xlsApp As Excel.Application
   Dim w As Workbook
   Dim S As Worksheet
   
   Set xlsApp = Excel.Application
   Set w = xlsApp.Workbooks.Open("D:\Mydocument.xls")
   Set S = w.Sheets("quotation")
   
   On Error GoTo dbErrHandler
   ' Display the Print dialog box
   cbdPrint.ShowPrinter
   ' Get user-selected values from the dialog box
   intBegin = cbdPrint.FromPage
   intEnd = cbdPrint.ToPage
   intNumCopies = cbdPrint.Copies
   
   ' Print as many copies as needed
   For intI = 1 To intNumCopies
      S.PrintOut
   Next intI
   Exit Sub

dbErrHandler:
   ' User pressed Cancel button
   Exit Sub
End Sub

HAGD:O)Bruintje
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7115216
sorry, what is cbdPrint variable?
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7115225
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:PNJ
ID: 7115832
You can also do:

W.PrintOut Copies:=intNumCopies, ActivePrinter:=OutPrinter

Where "OutPrinter" is any printer in your printers folder and this doesn't set the printer to the default.
0
 
LVL 2

Author Comment

by:chandukb
ID: 7116584
ThankX a lot
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7116997
glad i could help
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 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