Sign in to follow this  
Followers 0
Read

Excel 2003 / data

19 posts in this topic

Sheet: January 2011 and A1 February.

How can it: February ???

Code: _ExcelWriteCell($oExcel, "January", "A1")

February 2011 is empty - That's bad.

I want:

January 2011 and A1 January.

February 2011 and A1 February

How to use Bold/color? <B>January</B>

#include <Excel.au3>
Local $January = "January 2011"
$oExcel = _ExcelBookNew()
With $oExcel
        .ActiveWorkbook.Sheets(1).Name = $January
    EndWith
    $oExcel.Range("A1").Select
    
_ExcelWriteCell($oExcel, "January", "A1")

Local $February = "February 2011"
With $oExcel
        .ActiveWorkbook.Sheets(2).Name = $February
    EndWith
    $oExcel.Range("A1").Select
    
_ExcelWriteCell($oExcel, "February", "A1")

Thanks

Share this post


Link to post
Share on other sites



You didn't change the active sheet to Sheets(2) just by renaming it, did you? So _ExcelWriteCell() is going to Sheets(1) both times. Try _ExcelSheetActivate().

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I'm bored. Less mess.

#include <Excel.au3>
$mJan = 'January 2011'
$mFeb = 'February 2011'
$oExcel = _ExcelBookNew()
_ExcelSheetNameSet($oExcel, $mJan)
_ExcelWriteCell($oExcel, StringTrimRight($mJan, 5), 1, 1)
_ExcelSheetActivate($oExcel, 2)
_ExcelSheetNameSet($oExcel, $mFeb)
_ExcelWriteCell($oExcel, StringTrimRight($mFeb, 5), 1, 1)

Share this post


Link to post
Share on other sites

Hmm, I assume that i am doing something wrong.

Error (Line9): Incorrect number of parameters in function call

I searching forum "_ExcelSheetActivate()" only 2 post :)

#include <Excel.au3>
Local $January = "January 2011"
$oExcel = _ExcelBookNew()
With $oExcel
        .ActiveWorkbook.Sheets(1).Name = $January
    EndWith
    $oExcel.Range("A1").Select
    
_ExcelSheetActivate($oExcel, "January", "A1")

Local $February = "February 2011"
With $oExcel
        .ActiveWorkbook.Sheets(2).Name = $February
    EndWith
    $oExcel.Range("A1").Select
    
_ExcelWriteCell($oExcel, "February", "A1")

You didn't change the active sheet to Sheets(2) just by renaming it, did you? So _ExcelWriteCell() is going to Sheets(1) both times. Try _ExcelSheetActivate().

;)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Work but more easily. Im noob, sorry.

Where you take January and February? If I want write A1 "Welcome" how them?

I'm bored. Less mess.

#include <Excel.au3>
$mJan = 'January 2011'
$mFeb = 'February 2011'
$oExcel = _ExcelBookNew()
_ExcelSheetNameSet($oExcel, $mJan)
_ExcelWriteCell($oExcel, StringTrimRight($mJan, 5), 1, 1)
_ExcelSheetActivate($oExcel, 2)
_ExcelSheetNameSet($oExcel, $mFeb)
_ExcelWriteCell($oExcel, StringTrimRight($mFeb, 5), 1, 1)

Edited by Read

Share this post


Link to post
Share on other sites

Someone? wakillon?

Share this post


Link to post
Share on other sites

The script as-is, as written by TwistedGA, will open Excel and make the first sheet's name "January 2011", then cell A1 says "January".

Sheet 2's name becomes "February 2011" and A1 on that sheet says "February".

So what else did you need to do?

Share this post


Link to post
Share on other sites

Work but more easily. Im noob, sorry.

Where I use A1 "text" B6 "text"

Where you take January and February? If I want write A1 "Welcome" how them?

You can write to a cell two basic ways using _ExcelWriteCell, they are:

_ExcelWriteCell($oExcel, 'Some Text', 1, 1);1, 1 = row1, col1

$var = 'Some Text'
_ExcelWriteCell($oExcel, $var, 1, 1);1, 1 = row1, col1

To make A2 read 'Welcome', I would add this line to my previous posts script.

I chose A2 to keep February in Cell A1.

_ExcelWriteCell($oExcel, 'Welcome', 2, 1)

Share this post


Link to post
Share on other sites

B4 "Text" > Right (xlRight)

How make it?

$oExcel.Cells(4, 2).Value = "Text" ;B4
$oExcel.Range("B4").Select
$oExcel.Selection.Font.Bold = True
With $oExcel.Selection.Font
.Name = "Arial"
.Size = 10

I tried to change it

$oExcel.Activesheet.Columns("B:B").HorizontalAlignment = 4;

vs

$oExcel.Activesheet.Columns("B4").HorizontalAlignment = 4;

Yes, it's not work ;)

Share this post


Link to post
Share on other sites

Try:

$oExcel.Range("B4").Select
$oExcel.Selection.HorizontalAlignment = -4152

Share this post


Link to post
Share on other sites

Too easy ;) Work.

Thanks

Try:

$oExcel.Range("B4").Select
$oExcel.Selection.HorizontalAlignment = -4152

Share this post


Link to post
Share on other sites

You're welcome. If you prefer, you can use the constant from the Excel.au3 UDF:

$oExcel.Selection.HorizontalAlignment = $xlRight

Too easy ;) Work.

Thanks

Share this post


Link to post
Share on other sites

Posted Image

What Borders is it or where i can see list?

$oExcel.Selection.Borders.LineStyle = number

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Open up Visual Basic Editor (from Excel press ALT+F11) then press F2 when you get into Visual Basic to get you into Object Browser. From there do a search for "xlLineStyle".

Edited by MrMitchell

Share this post


Link to post
Share on other sites

I did code but number is wrong / -4115

And this site not help me or help: http://msdn.microsoft.com/en-us/library/aa221100%28v=office.11%29.aspx

$oExcel.Range("B7:F31").Select
$oExcel.Selection.Borders.LineStyle = -4115

Open up Visual Basic Editor (from Excel press ALT+F11) then press F2 when you get into Visual Basic to get you into Object Browser. From there do a search for "xlLineStyle".

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I did code but number is wrong / -4115

And this site not help me or help: http://msdn.microsoft.com/en-us/library/aa221100%28v=office.11%29.aspx

$oExcel.Range("B7:F31").Select
$oExcel.Selection.Borders.LineStyle = -4115

xlContinuous = 1

Edit:

Like so: $oExcel.Selection.Borders.LineStyle = 1

$oExcel.Selection.Borders.Weight = 1

Edited by JoHanatCent

Share this post


Link to post
Share on other sites

How to add a comment?

Here is the error I think: .Comment.Text text="123:"

$oExcel.Range("E7").AddComment
$oExcel.Range("E7").Comment.Visible = False
$oExcel.Range("E7").Comment.Text text="123:" & Chr(10) & "1234"

Share this post


Link to post
Share on other sites

Nobody knows, how to add a comment in Excel?

Share this post


Link to post
Share on other sites

Nobody knows, how to add a comment in Excel?

$oExcel.Range("E7").Comment.Text("Comment:" & Chr(10) & "1234")

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  
Followers 0