(SOLVED) Macro to print

SteveC

Board Regular
Joined
Mar 14, 2002
Messages
118
I recorded a macro to print a section of my sheet that lies outside of the normal print range. The name of the file will change when it is used. The problem I see is that in the macro below, it refers to the current file name. How can I get this to work no matter what the file name changes to?
Thank you for your help - and May the Code Be With You.
SteveC

Sub PRINTTIMESbuttonAtTimesList()
..... Selection.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
..... Application.Run _
..... "'LOG Template.xls'!VIEWTIMES_and_TopOfTimes_Buttons"
End Sub
This message was edited by SteveC on 2002-10-05 05:07
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

stevebausch

Well-known Member
Joined
May 11, 2002
Messages
810
This sounds like a homework question.


ThisWorkbook would normally work when this question is asked. Your code is different.

And I can't understand why it is written this way.

So I will just watch this thread, see what the responses are.
This message was edited by stevebausch on 2002-10-03 23:21
 

SteveC

Board Regular
Joined
Mar 14, 2002
Messages
118
Regarding this code: This is how the macro recorder wrote it. All I did was select the portion that I wanted to print; select print; and the selection option and portrait option in print; then press another button which repositions the page.
Any ideas on what I need to do to have the macro work no matter what the file name is?

Actually there is one other thing that I can't figure out. Within the print area selected (DM192:DP358), I would like it to print only those lines that have any cells with numbers. It should not see a formula as a number. If it helps, all of the blank lines will be at the bottom.

Thank you for any help.
SteveC
This message was edited by SteveC on 2002-10-04 03:08
 

SteveC

Board Regular
Joined
Mar 14, 2002
Messages
118
Hi
Is there anyone that has an idea how to use a macro to print a range even after the file name changes?
Please let me know if I need to clarify anything.
Thanks.
SteveC
 

ROBINSYN

Board Regular
Joined
Aug 19, 2002
Messages
188
Not sure if this will help but works everytime I rename my file or sheet.

Sub Print()

Range("A1:O46").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$O$46"
ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=False
Range("P2").Select
End Sub
 

SteveC

Board Regular
Joined
Mar 14, 2002
Messages
118
Thank you for your help Robinsyn. You set me in the right direction. After several hours of hair pulling, I put together something that works. I know there has to be a better way. If anyone sees how this can be improved, please let me know. Thank you.
This is it:

Sub PRINTTIMESbuttonAtTimesList()
...'Print the "TIMES" list
....'SELECT RANGE, PORTRAIT, ETC. THEN PRINT
....Range("DM191:DP358").Select
....With ActiveSheet.PageSetup
........ .Orientation = xlPortrait
....Selection.PrintOut From:=1, To:=1, Copies:=1
....End With

'GO TO A POSITION ON SHEET
....Application.GoTo Reference:=Range("DF194"), Scroll:=True

'RESET TO NORMAL: PRINT RANGE & ORIENTATION
....ActiveSheet.PageSetup.PrintArea = "$A$1:$AQ$148"
....With ActiveSheet.PageSetup
........ .Orientation = xlLandscape
....End With
End Sub
This message was edited by SteveC on 2002-10-05 04:04
 

Forum statistics

Threads
1,144,307
Messages
5,723,627
Members
422,505
Latest member
Noar33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top