ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook Open Macro (https://www.excelbanter.com/excel-programming/341907-workbook-open-macro.html)

natarajr

Workbook Open Macro
 

This below macro used to work in the older version of excel. It does
not work now. Any help is appreciated!!
Thanks

Sub OpenPrintMacro()

Dim Fname

For i = 1 to 5

Fname = Worksheets("FileNames").Range("a"+i).value
Workbooks.open.filename:= "C:\My Documents\Files\" & Fname
ActiveWindow.selectedsheets.Printout copies:=1
ActiveWorkbook.close

Next i
End Sub




WorkSheet FileNames

Range a1 = Test1.xls
Range a2 = Test2.xls
Range a3 = Test3.xls
so on and so forth.............


--
natarajr
------------------------------------------------------------------------
natarajr's Profile: http://www.excelforum.com/member.php...o&userid=27807
View this thread: http://www.excelforum.com/showthread...hreadid=473174


Dave Peterson

Workbook Open Macro
 
It sure looks like it would work if the values in the A1:A5 corresponded to
real filenames in "c:\my documents\files".

I'd check that first.

If that isn't it, you may want to post what happens when it fails.

natarajr wrote:

This below macro used to work in the older version of excel. It does
not work now. Any help is appreciated!!
Thanks

Sub OpenPrintMacro()

Dim Fname

For i = 1 to 5

Fname = Worksheets("FileNames").Range("a"+i).value
Workbooks.open.filename:= "C:\My Documents\Files\" & Fname
ActiveWindow.selectedsheets.Printout copies:=1
ActiveWorkbook.close

Next i
End Sub

WorkSheet FileNames

Range a1 = Test1.xls
Range a2 = Test2.xls
Range a3 = Test3.xls
so on and so forth.............

--
natarajr
------------------------------------------------------------------------
natarajr's Profile: http://www.excelforum.com/member.php...o&userid=27807
View this thread: http://www.excelforum.com/showthread...hreadid=473174


--

Dave Peterson


All times are GMT +1. The time now is 12:22 AM.

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