Jump to content
Sign in to follow this  
iahngy

Excel zoom 75% , set font, and color for the cell

Recommended Posts

iahngy

Hi there,

Below is the function i a m trying to make for zooming to 75 % on an active sheet of Excel..But i dont know the name of the method/ function for zooming,

also setfont to "courier new" , and color for the cell... Trying to get com viewer from msdn but couldnt find it.

Would you please give me some hints, I m very appreciated.

Func _ExcelZoom($sFilePath ,$sheet)

Local $oExcel = ObjCreate("Excel.Application")

With $oExcel

.visible = 1

.WorkBooks.Open($sFilePath)

.ActiveWorkbook.Sheets($sheet).Select()

EndWith

Return $oExcel

EndFunc ;4

Share this post


Link to post
Share on other sites
water

$oExcel.Activewindow.Zoom = 75

To set color/font of cells you have to define a range and then set the properties for this range.

The Excel COM Reference can be found here (Excel 2007).

BTW: You are posting in the wrong forum - use General Help and Support forum.

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
iahngy

Is there a function to read the row and colum name ...since I try to put lots of text in and it will expand ..so dont know the range to enter for font setting

Share this post


Link to post
Share on other sites
water

Do you want to set the font for the whole worksheet?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
iahngy

Yes..whole worksheet...

Share this post


Link to post
Share on other sites
water

To set the font for all cells use:

$oRange = $oExcel.ActiveWorkbook.Sheets(1).UsedRange
$oRange.Font = "Courier New"


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

With "color for the cell" you mean the background color or the font color?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
iahngy

i found the function to set cell color background

ActiveWorkBook.Sheets($sheet).range("A5").interior.ColorIndex = 45

Thing is the excel is automated : it is writen text from many files and put all file's text on...so the colum and row names at certain point is unknown ..I think i can write a code to put together like A and 8 for row 8 and D for colum 4 since the colum and row # can get from variables...Just wonder if excell has built in for reading names A, or B, C ,D if it is given the colum and row #..I guess not ? :)

Would you give me function to change text color for certain row-colum.

Thank you.

Edited by iahngy

Share this post


Link to post
Share on other sites
water

I can't test at the moment but I think

ActiveWorkBook.Sheets($sheet).range("5:5").interior.ColorIndex = 45
sets the color for row 5.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×