ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Files (https://www.excelbanter.com/excel-programming/320315-open-files.html)

Jordan

Open Files
 
Hello,
I have a ton of files that need to be opened and printed. I have a list of
their names in an excel spread sheet and I am wondering if it is possible to
write a program that would open up each of those files and/or print them off.
All the files are tif files.

I have tried:
Open "C:\Documents and Settings\JSena\My Documents\ECOacksheet1" For Input
Access Read Lock Read As #1 'if I run this twice it gives me an error
because the file is already opened, but I can not see it as opened.

also tried:

fileToOpen = Application _
.GetOpenFilename()
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If 'but obviously this does not actually open the file, and don't know
how to make it.

also tried:
Application.FindFile 'and this seems like it would work if only I could
enter aruguments so that it could find the files on its own as long as I gave
it the paths.

Thank you very much for any help with this,
Jordan



Bernie Deitrick

Open Files
 
Jordan,

Set a print area that is large enough to hold your largest tif file, and use
page setup to set the print to fit to 1 page. The specific code of how to
open the file depends on how your file names are stored: if the have the
..tif at the end, then you can delete the & ".tif" part of the code. If they
have the drive and folder path in the cell, then you can delete the
C:\Foldername part. (It would have been helpful if you posted an
example...).

Anyway, after you set up the page, run a macro like this:

Sub JordanTifPrint()
Range("B1").Select ' this is the top left cell of your print range

For Each myCell In Range("A1:A100") ' this is your list
ActiveSheet.Pictures.Insert("C:\FolderName" _
& myCell.Value & ".tif").Select
ActiveSheet.PrintOut
Selection.Delete
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP

"Jordan" wrote in message
...
Hello,
I have a ton of files that need to be opened and printed. I have a list

of
their names in an excel spread sheet and I am wondering if it is possible

to
write a program that would open up each of those files and/or print them

off.
All the files are tif files.

I have tried:
Open "C:\Documents and Settings\JSena\My Documents\ECOacksheet1" For Input
Access Read Lock Read As #1 'if I run this twice it gives me an

error
because the file is already opened, but I can not see it as opened.

also tried:

fileToOpen = Application _
.GetOpenFilename()
If fileToOpen < False Then
MsgBox "Open " & fileToOpen
End If 'but obviously this does not actually open the file, and don't

know
how to make it.

also tried:
Application.FindFile 'and this seems like it would work if only I

could
enter aruguments so that it could find the files on its own as long as I

gave
it the paths.

Thank you very much for any help with this,
Jordan






All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com