Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old April 28th, 2008, 09:51 AM
ryland22 ryland22 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 ryland22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 55 sec
Reputation Power: 0
General Scripting - How to print a file

I read the tutorial on how to print files in a folder, and that worked great, but I just need to print one file and cannot get it to work. This is what I've tried so far:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\text.txt", 1)
Set objShell = CreateObject("Shell.Application")

objFile.InvokeVerbEx("Print")

objFile.Close

--------------------------------------------

That didn't work so I tried this:

TargetFile = "c:\text.txt"
Set objShell = CreateObject("Shell.Application")
Set objFile = objShell.Open(TargetFile)

objFile.InvokeVerbEx("Print")

That also doesn't work along with about 20 other variations I have tried. I can't seem to set the file as an object, and then print the file.

Reply With Quote
  #2  
Old April 29th, 2008, 06:54 PM
keep_it_simple's Avatar
keep_it_simple keep_it_simple is offline
KIS
ASP Free Novice (500 - 999 posts)
 
Join Date: Jul 2007
Location: USA
Posts: 969 keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level)keep_it_simple User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 3 h 4 m 57 sec
Reputation Power: 280
Send a message via Yahoo to keep_it_simple
Code:
TargetFolder = "C:\" 
TargetFile = "test.txt"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder) 
Set colItems = objFolder.Items

iFileCount = colItems.count
i = 0

For each objItem in colItems
 If objItem = TargetFile Then 
   objItem.InvokeVerbEx("Print")
   Exit For
 End If

  i = i + 1

 If i = iFileCount Then Msgbox("File not found")
 
Next
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon

Last edited by keep_it_simple : April 29th, 2008 at 07:06 PM. Reason: used requested file name

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > General Scripting - How to print a file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway