Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / October 2004



Tip: Looking for answers? Try searching our database.

Print automation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Lawrence - 16 Oct 2004 17:21 GMT
I am looking for a way to automate some of my printing tasks, which, I
would be able to do if it were not for this problem. I have a directory
(which I know the name of). In this directory is a bunch of
subfolders(which I DON'T know the name of- unless I actually open the
main
directory). Each of these subfolders contain a .tif image (which has
random names) that I need to print. I have tried using vbscript for this
purpose, but being that I cannot use wildcards for the subfolders I am
running into a roadblock. How can I get around the unknown subfolder
names? Thanks for any help!

Martin
tlviewer - 17 Oct 2004 02:23 GMT
> I am looking for a way to automate some of my printing tasks, which, I
> would be able to do if it were not for this problem. I have a directory
[quoted text clipped - 6 lines]
> running into a roadblock. How can I get around the unknown subfolder
> names? Thanks for any help!

This sub will accept your root_folder [in] and an array [in,out]
and will recurse for all files. Change the *.* to *.tiff to filter
for your images. It's very quick.

Public Sub GetDir(ByVal path As String, ByRef Arr As Variant)

Dim sfile As String
Dim sFold() As String
Dim nK As Long
Const sRoutine As String = "GetDir"
On Error GoTo err_GetDir
sfile = Dir(path & "*.*", vbDirectory)  '<-- add filter here
'
nK = 0

Do While Len(sfile) > 0
 'Debug.Print "sfile=", sfile
 If Left$(sfile, 1) Like ("[.%]") Then GoTo DO_NEXT

 If (GetAttr(path & sfile) And vbDirectory) > 0 Then

   'Debug.Print path & sfile & "\"
   ReDim Preserve sFold(0 To nK)
   sFold(nK) = path & sfile & "\"
   nK = nK + 1
'    GetDir path & sfile & "\", Arr
'    Debug.Print "succesfully recur"
 Else
   ReDim Preserve Arr(0 To nJ)
  ' Debug.Print sfile
   Arr(nJ) = LCase(sfile)
   nJ = nJ + 1
 End If
DO_NEXT:
 sfile = Dir(, vbDirectory)
Loop

' handle sub folders
If nK > 0 Then
 For nK = 0 To UBound(sFold)
   GetDir sFold(nK), Arr
 Next
End If

Exit Sub
err_GetDir:
 Debug.Print sfile, Err.Number, Err.Description
 'Err.Raise Err.Number, "CSort" & "." & sRoutine, Err.Description
End Sub

hth,
tlviewer
Martin Lawrence - 25 Oct 2004 18:53 GMT
I left this info out of my original post and I'm sure it makes a
difference. The folder names are being extracted from an Excel
spreadsheet. What I need this code to do is get the 1st folder name from
the spreadsheet and print what's in that folder, then get the next
folder name from the spreadsheet. This should be repeated until all
items have been printed.

Now--- I tried attaching this code to a command button on the
spreadsheet and the error message I'm getting is "Expected End Sub" and
the debugger is pointing to the first line "Private Sub
commandbutton1_click()". Should this code be placed in a module, or
directly connected to the command button? Also, I assume that with the
code that was provided, all I need to do is insert the path of the root
folder and change the "*.*" to  "*.tif"

Martin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.