Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Before Print and UnDo

Hi all,


Is it possible to change the row height and column width of a range in
a sheet when the user Print the sheet and return it back to the
original state?


like for eg. when the user executes the print command change the row
hight to 20 and column width to 10 on my range A1:M20 and return it to
what ever width and height was it previously.

I would like to have this facility through an AddIn so I can make it
available globaly


TIA
Soniya

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Before Print and UnDo

See reply in excel.misc


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Soniya" wrote in message
oups.com...
Hi all,


Is it possible to change the row height and column width of a range in
a sheet when the user Print the sheet and return it back to the
original state?


like for eg. when the user executes the print command change the row
hight to 20 and column width to 10 on my range A1:M20 and return it to
what ever width and height was it previously.

I would like to have this facility through an AddIn so I can make it
available globaly


TIA
Soniya



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Before Print and UnDo

thanks for your kind reply..
only column width changes and not row height?!!

is it possible to make this an addin so i can have this on every
workbook?

thanks


Hi Soniya,



This should do it



Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim aryWidths(1 To 13)
Dim nRow As Double
Dim i As Long
With ActiveSheet
Application.EnableEvents = False
Application.ScreenUpdating = False
For i = 1 To 13
aryWidths(i) = .Columns(i).ColumnWidth
.Columns(i).ColumnWidth = 10
Next i
nRow = .Rows(1).RowHeight
.Rows(1).RowHeight = 20
Cancel = True
.PrintPreview
.Rows(1).RowHeight = nRow
For i = 1 To 13
.Columns(i).ColumnWidth = aryWidths(i)
Next i
Application.ScreenUpdating = True
Application.EnableEvents = True
End With



End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Before Print and UnDo


"Soniya" wrote in message
oups.com...

only column width changes and not row height?!!


Uh?

is it possible to make this an addin so i can have this on every
workbook?


Add this to the addin

Option Explicit

Dim WithEvents app As Application

Private Sub Workbook_Open()
Set app = Application
End Sub

Private Sub app_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
Dim aryWidths(1 To 13)
Dim nRow As Double
Dim i As Long
With Wb.ActiveSheet
Application.EnableEvents = False
Application.ScreenUpdating = False
For i = 1 To 13
aryWidths(i) = .Columns(i).ColumnWidth
.Columns(i).ColumnWidth = 10
Next i
nRow = .Rows(1).RowHeight
.Rows(1).RowHeight = 20
Cancel = True
.Printout
.Rows(1).RowHeight = nRow
For i = 1 To 13
.Columns(i).ColumnWidth = aryWidths(i)
Next i
Application.ScreenUpdating = True
Application.EnableEvents = True
End With

End Sub


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Before Print and UnDo

Thanks Again. It works fine
except as I noted earlier Row heigh sees not changing
Also when I try to print a sheet using the code

Sheets("ABC").PrintOut instead of ActiveSheet, how I cud modify the
code to get it work?

Thanks again



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Before Print and UnDo


"Soniya" wrote in message
ups.com...
Thanks Again. It works fine
except as I noted earlier Row heigh sees not changing


It works for me. Perhaps you need a bigger height.

Also when I try to print a sheet using the code

Sheets("ABC").PrintOut instead of ActiveSheet, how I cud modify the
code to get it work?


Why would you not want to print the activesheet?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Before Print and UnDo

Normally it will be the ActiveSheet. But I (and some users) have
already some working files in which there are several lines of code
where I used sheets("SheetName").PrintOut. at that time i thought it
will be more fast and saving lines of coding. Especially when you have
to do the printing from another sheet and come back to the same sheet
after the printing I think it is easy to print without selecting the
sheet itself.

I use the activesheet to fill a form and based on a value in my cell it
prints a specific sheet.It can be one out of several sheets.

I think there would be a wayout to do this rather than modifying code
in other sheets. Exxcel could identify which sheet is going to print
and in that sheet before printing i want to adjust the widths.


thanks for your assistance.

Soniya

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Instead of one by one Undo karthikbalaguru Excel Discussion (Misc queries) 4 February 5th 09 05:03 PM
Can't undo Mesak Excel Discussion (Misc queries) 3 August 24th 07 01:17 PM
Before Print and UnDo [email protected] Excel Discussion (Misc queries) 6 October 15th 05 05:17 PM
UNDO - how many times can I UNDO? Jane Excel Worksheet Functions 2 May 19th 05 03:03 AM
Why is my undo function in Excel only can undo the last 1 or 2 ch. 1111111111111111111111111111111111111111 Excel Worksheet Functions 1 November 24th 04 11:13 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"