|
The method you are using here will start the application which is associated with the filetype in FileName .
What you should be doing is create an instance of the application's automation object (which won't show the UI) and then use that object's methods to manipulate the file as appropriate.
Something like this... but beware this code is not complete - you'll need to do some further research for the exact sequence etc. but you get the idea...
Dim ExcelApp As Microsoft.Office.Interop.Excel.Application
ExcelApp = New Microsoft.Office.Interop.Excel.Application
ExcelApp.Visible = False
ExcelApp.Workbooks.Open(filePath.ToString())
ExcelApp.Worksheets.PrintOut(...)
Don't forget to include a reference to the Microsoft Excel 11.0 Object Library (from Project -> References -> COM tab etc...).
...Steve
|
|
|
|
|
ok ill try it but what should i do for .doc and pdf format acutally it doesnot open the application for .ppt format but it does for three(.doc,.xls,.pdf). do you have any general idea?.
actually i have to print the document without open any windows printing window.
Raheel Iqbal
|
|
|
|
|
Use the correct automation object for each type of file: e.g. .doc and .pdf (?) = Word.Application; .ppt = PowerPoint.Application.
The basic idea is given in my earlier response. You'll need to read up on the methods of each object (should be fairly similar) to find out how to achieve your requirements.
...Steve
|
|
|
|
|
Dim Wordapp As Microsoft.Office.Interop.Word.Application
Wordapp = New Microsoft.Office.Interop.Word.Application
Wordapp.Visible = False
Wordapp.Documents.Open(filePath.ToString())
Wordapp.PrintOut(, , , , , , , 2, , , , , filePath.ToString())
Wordapp.Quit()
hi steve.
for (.doc) file i use this coding but by using this i m facing the same problem that it opens the doc application, will you please see this and guide me if you have any knowledge, and i did`nt find any class for acrobat file... will you please guide me some.
Raheel Iqbal
|
|
|
|
|
raheeli wrote: i m facing the same problem that it opens the doc application,
Hmmm... works for me without showing the UI (I'm using Office 11 objects). Do you mean that it is starting an instance of WINWORD.EXE as shown in the Task Manager? If so that is correct since that EXE is required to perform the printing of the specified document.
However I'd change this line:
Wordapp.PrintOut(, , , , , , , 2, , , , , filePath.ToString()<br />
to this:
Wordapp.PrintOut(, , , , , , , 2)<br />
otherwise you'll be probably printing to a file rather than the printer - and overwrite the input file in the process.
As far as PDF files are concerned, there is no COM object similar to that provided for the Microsoft applications that I know about to do what you want but I did find this via a Google search re: Acrobat commandline options to automate the print process.
[From the DEVFAQ]<br />
AcroRd32.exe filename - Executes the Reader and displays a file..<br />
AcroRd32.exe /p filename - Executes the Reader and prints a file..<br />
AcroRd32.exe /t path printername drivername portname - Initiates Acrobat<br />
Reader,,<br />
prints a file while suppressing the Acrobat print dialog box,then terminates<br />
Reader.<br />
The four parameters of the /t option evaluate to<br />
path,printername,drivername,and<br />
portname (all strings).<br />
printername - The name of your printer..<br />
drivername - Your printer driver 's name.Whatever appears in the Driver Used<br />
box<br />
when you view your printer 's properties.<br />
portname - The printer 's port.portname cannot contain any "/"characters;if<br />
it does,<br />
output is routed to the default port for that printer.<br />
If using Acrobat,substitute Acrobat.exe in place of AcroRd32.exe in the<br />
command lines.<br />
...Steve
|
|
|
|
|
Thanks steve you help me alot,really and its worthy for me.
Steve is there any General method by which i can solve my problem, it become head ache for me cause, as per requriement of format of printing increase i have to work out on that(now i had requirements of TIFF, JPEG, etc....) and may be in future it increases, do you have any general solution?
Actually i have to made a printing solution in which user can enter the number of copies and select the files, which he want to print. but no any operating system printing window should open.
Thankyou very much steve. please if you have any solution the reply me as soon as you can.
Raheel Iqbal
|
|
|
|
|
As far as I'm aware you need to open the correct application for the type of file you want to print, and then print via that application. Your code needs to do this.
I did a Google search for "automate printing files different formats" and found this hit in the results: http://www.silentprint.com/[^] which is a ready-built application for what you are attempting to do. This will save you a heap of headaches. However if you must do this code yourself (i.e. for project/assignment or other reasons) then you'll need to have your own code be aware of all the types of documents likely to be printed and handle them accordingly.
Note - I do not have any interest in the company or product referenced above. I simply found it as one of the hits on Google. There are others that you may want to check out.
...Steve
|
|
|
|
|
Thanks steve. but this is my project/assignemnt i can not use this product anyways will try to find from other links thanx once again you help me alot if you find any other solution... please let me know
Raheel Iqbal
|
|
|
|
|
Does anyone have a decent pizza ordering program out there. I'm trying to build one as we speak, having no luck
|
|
|
|
|
Are you trying to start a pizza shop, or is this homework ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
OK, well, the first thing you need to understand is that if I do your homework for you today, you won't have a clue how to do your next assignment, which will assume that you did this one. The second thing you need to understand is that, homework or not, it's pretty rare for anyone who asks 'I need someone to give me this application' to get the answer they want.
What does your assignment say ? What have you already written ? What bits are you stuck on ? If you demonstrate that you've tried to solve the problem and ask specific questions for where you are stuck, then this site is full of people who would love to help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There won't be a next assignment..this is a makeup one I'm working on as the class is over. Here's what it entails
Well designed GUI
Use a menu
Use 3 different controls (intrinsic or ActiveX)
Have a print capability
Implement an application that allows employees of a pizzeria to place customer orders.
Customer info must include name, telephone #, and address
Customer can pay using a visa, mastercard, check or cash
If they pay using credit card or check, the user needs to enter the customers check or credit card number
At least three pizza sizes. Small, medium and large. Six toppings must be available. Prices of pizza and toppings shown on form (toppings are .75 each). Sales tax of 6%
All pricing calculated when user clicks "Place an order"
If no pizza size or toppings are selected, a msg box must appear telling user that it needs to be entered.
clicking "New order" button clears all entries on form
|
|
|
|
|
So what have you done already ? Where do you need help ? I take it you intend to never program a computer again in your life, and you're looking for a free ride out of this class ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
How to grab a Frame from an MPEG movie (in VB .net), without saving an image file on harddisk. I've been searching alot for an answer and i couldn't find it. i've using mediadet.writebitmapbits, but this doesn't work for me cause i want to analyse a long video file and i don't want to save each and every frame on my harddisk.
Sam
|
|
|
|
|
If you want to analyse an entire file, perhaps you need to create a filter for DirectShow that does the analysis you're after ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
tanx alot for ur reply but I have bigun to study vb.net just for a month, so I don't know where shoul I write these code to, please tell me about it.
|
|
|
|
|
Hi
First of all, a language compiler is very sensitive to spelling. Lucky for you, VB.NET is not case sensitive, but you still need to spell things correctly.
Secondly, if you're replying to a post below, you should press 'reply', then the person who answered you will get an email, and the boards won't become an unreadable mess. You may have missed it, but these boards support threading, where you can see exactly who has replied to who.
Having read your question below, I'd have to suggest that you obviously are not at a point where you should be trying to do anything remotely this complex. The world is full of people who try to start programming by writing useful applications, most of them never write one thing worth looking at. If you want to learn, start simple, and build from there. If you don't know 'where to put the code', then you should not be using it, or trying to impliment what you're trying at the moment. You should write a few console apps, such as a basic calculator. Then start playing with some WinForms and learn how that sits on top of VB.NET. Then, when you've got enough of an understanding to be able to use the help that people offer you here, you can start working on something more complex, and ask questions as you get stuck.
Of course, you can ask more basic questions as you work through some more basic examples, also. We're here to help, but you need to do some work too
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi everyone, I was wondering if anyone knows what the syntax would be to access a microsoft access database query and populate a dataadapter/dataset with the resulting table? Thank you
eatwork
|
|
|
|
|
Search msdn for dataset class, that should get you started.
|
|
|
|
|
Hi KaptinKrunch,
Thanks for the reply. I did the search in msdn for the dataset class and could not find the syntax to populate a dataset based on a query created within the ms access database. All of the articles I read were populating the dataset based on a user defined Select statement within their code. would you be able to post the actual url where you found this information? thank you.
eatwork
|
|
|
|
|
Dim MyConnectionString as String = "Jet OLEDB:Registry Path=;User ID=Admin;Jet OLEDB:System database=;Data Source=""C:\MyDatabase.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";Persist Security Info=False;Jet OLEDB:Global Partial Bulk Ops=2;Mode=ReadWrite;Extended Properties="";COUNTRY=0;CP=1252;LANGID=0x0409"""
Dim MyConnection As New OleDbConnection(MyConnectionString)
Dim MyAdapter As New OleDbDataAdapter
Dim MyDataTable as New DataTable
MyAdapter.SelectCommand = New OleDbCommand("select * from MyTable", myconnection)
MyAdapter.Fill(MyDataTable)
Read a book on the subject! There is so much to learn.
|
|
|
|
|
Hi dptalt,
Thank you for your response. I am able to access the tables in the database, but my question was directed towards opening queries created within the access database without using the "select * from mytable". Or does your message mean that I can use a "select * from myquery" to return the results from a query? Thank you.
Eg. I have a query named qryWheelRatesList, the query utilizes another query within it and I was wondering if I need to combine the two select statements together to retrieve results, or if there was syntax that would allow me to open the query itself and return the values within the query so I don't have to create a long and complicated select statement. Thank you.
eatwork
|
|
|
|
|
Hi dptalt and kaptinKrunch
I have found the solution to my problem. It was because because I had split the database and the queries were not included on the database that we were trying to access. THank you for all of your help.
eatwork
|
|
|
|
|