?
Solved

Printing from VB

Posted on 2000-02-18
8
Medium Priority
?
155 Views
Last Modified: 2010-05-02
Hi,
  I am interested in a program that will check files into a directory and print their files.
  The problem is that I don´t know how to check a file (for example .doc) and print it automaticly. Is it posible?.

  Can you tell me how to do it or point me somewhere?.

Thks!.

Alejandro Acosta A.
0
Comment
Question by:aacosta
[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
  • 5
  • 2
8 Comments
 
LVL 14

Expert Comment

by:mcrider
ID: 2536030
See the microsoft KB article:

HOWTO: Use ShellExecute to Launch Associated File (32-bit)
http://support.microsoft.com/support/kb/articles/Q170/9/18.asp?LNG=ENG&SA=MSDN&FR=1 


In the example you will see the line:

   StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _
          "", "C:\", SW_SHOWNORMAL)
     

If you change the "Open" to "Print" in this line, it will print the document to the default printer using the native application that the file belongs to.  For example, a .DOC file is associated with Word.  This will print the document through word...


Cheers!
0
 
LVL 14

Accepted Solution

by:
mcrider earned 400 total points
ID: 2536064
By the way, if you dont want to have the application visible, you would change that line to:

   StartDoc = ShellExecute(Scr_hDC, "Print", DocName, _
          "", "C:\", 0)



Cheers!
0
 
LVL 6

Expert Comment

by:Marine
ID: 2536105
Its going to be a few more lines then mcrider proposed. Yes you would need to use ShellExecute to print this but to check files you would need something else. I'll see if i can find something for you to solve this. Can i do something like this. Put all the listed files from a directory into a FileList control and then when you click on that file you will print it is that good enough ?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Expert Comment

by:mcrider
ID: 2536184
I am assuming that aacosta knows how to select the files that are to be printed...  The problem was actually PRINTING the files...

If that was too big of an assumption, I'm sorry...

There are so many ways to select a file(s)...  It all depends on what you want your interface to look like.

You can use the CommonDialog control to select the file(s)...

You can use the DriveListbox DirListbox and FileListbox to select the drive/directory/file...

You can use the Dir statement to get the files in a directory...


All of these are WELL DOCUMENTED in the VB Help file.


aacosta, If you need any more information, let me know.



Cheers!

0
 
LVL 1

Author Comment

by:aacosta
ID: 2536225
Hi again.
  The document at http://support.microsoft.com/support/kb/articles/Q170/9/18.asp?LNG=ENG&SA=MSDN&FR=1 was great!. I already used the code and work great.

  Can you tell me in addition how to get the files that are into a directory?.

Thanks.

0
 
LVL 14

Expert Comment

by:mcrider
ID: 2536286
aacosta,

Thanks for the points! Glad I could help...

In my previous comment I mention several ways to get files... Do you have any idea which method you want to use?? (CommonDialog, FileListBoxes, or the DIR Statement??)


Cheers!
0
 
LVL 1

Author Comment

by:aacosta
ID: 2536404
I think dir Statement is ok.

I would like to print all the files that are into a directory and then move them to another directory. What is the best way?.

I dont want you to do my Job, I just need a help.

Thanks again :-)
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2536451
This code will show all of the files in the directory c:\windows\desktop to the debug window...

    Dim lFileName As String
    lFileName = Dir("c:\windows\desktop\*.*")
    Do While Not lFileName = ""
        Debug.Print lFileName
        lFileName = Dir()
    Loop


To move the files, you can use the FileCopy statement to copy the files to where you want it to go and then use the Kill statement to delete the original file...


Cheers!

0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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

764 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