Jump to content

Recommended Posts

Posted

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

Posted

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().

;)

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
Posted

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?

Posted

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)
Posted

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 ;)

Posted

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

$oExcel.Selection.HorizontalAlignment = $xlRight

Too easy ;) Work.

Thanks

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
Posted

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"

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...