Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Images into Report from a Folder

Status
Not open for further replies.

Paddya

Programmer
Apr 25, 2002
15
IE
I am working on a report that needs to print out all images for a part. The images for each part are stored in a folder which is named as the part no. For example in the folder called c:\pics\ there is a folder for each part.

Part No: AZ124
Contents of folder c:\pics\AZ124
AZ124.tif,
AZ124-1.tif,
AZ124-1a.tif,
AZ124-2.tif &
AZ124-3.tif

Part No: AZ125
Contents of folder c:\pics\AZ125
AZ125.tif,
AZ125-1.tif &
AZ125-2.tif

Not every folder contains the same number of images (ranges from 3 to 8). I am trying to built the report so the user is prompted for the part no, and the report pulls in all the files from the folder.

Any ideas?

Thanks in advance,
Paddy
 
I have some code that looks through a folder and populates a TreeDisplay control based on the folders and files that it finds there.


The important part -for what you want to do is the fso stuff

You need to include the "Microsoft Scripting Runtime" in your library references.



Code:
Private Sub PopulateTree(SourcePath As String)

Dim fso As Object
Dim objDisplay As Object
Dim objNode As Node
Dim MyFolder As Folder
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(SourcePath) Then
    ' First empty out the CRDisplay of any old data
    CRDisplay.Nodes.Clear
    CRDisplay.Requery
    Set MyFolder = fso.getfolder(SourcePath)
    Call GetSnapshots(MyFolder)
Else
    MsgBox "There is a error in the definition of the path I am expected to look in" & vbLf _
         & "The folder path " & SourcePath & vbLf _
         & "does not exist", , "Who's moved it ?"
End If
End Sub

Private Sub GetSnapshots(fld As Folder, Optional hld As Folder = Null)
On Error Resume Next
Dim subfld As Folder
Dim fil As file
Dim nodNew As Node
'MsgBox fld.Name
If hld Is Nothing Then
    Set nodNew = CRDisplay.Nodes.Add(, , fld.Name, fld.Name)
    nodNew.Expanded = True
Else
    CRDisplay.Nodes.Add hld.Name, tvwChild, fld.Name, fld.Name
    DoCmd.Echo True, "Researching the contents of folder " _
                    & MID(fld, Len(mconstrRoot) + 1)
End If
For Each subfld In fld.subfolders
    Call GetSnapshots(subfld, fld)
Next
For Each fil In fld.Files
'    MsgBox "fil.path = " & fil.path & vbLf _
          & "fil.name = " & fil.Name
'    MsgBox fil.Type, , "File Type"
    If fil.Type = "SnapShot File" _
    Or fil.Type = "Microsoft Excel Worksheet" Then
        CRDisplay.Nodes.Add fld.Name, tvwChild, fil.path, fil.Name
    End If
Next
End Sub


'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Thanks GLS,

But how exactly do I use this in my report?

Paddy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top