 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Should this be continued? |
| Yes |
|
93% |
[ 14 ] |
| No |
|
6% |
[ 1 ] |
|
| Total Votes : 15 |
|
| Author |
Message |
enigmatiqk
Joined: 13 Apr 2007 Posts: 28
|
Posted: Fri Apr 03, 2009 9:30 am Post subject: |
|
|
| Sean wrote: | | enigmatiqk wrote: | | i'm sorry, i will delete com and excel code | Thanks. COM_Error(0)/COM_Error(1) turns OFF/ON the error message box.
|
its ok if i want create a method in com.ahk
but i want use current com_invoke
i understand thats a stupid method (resumenext), but i would not copy the big method com_invoke just to don't show msgbox ...
just a noob method because i'm afraid to do something into com_invoke
i haven't read all post, but i have seen the copy (so move too) sheet method from your link
| Sean wrote: |
The code in that thread is the exact one which you have to resort to when the following code will not work for you.
| Code: | | stockSheet := COM_Invoke(WorkBook, "Sheets.Add", "-0", "+" COM_Invoke(WorkBook, "Sheets", COM_Invoke(WorkBook, "Sheets.Count"))) |
|
i think its the code to add a sheet into defined position, but i haven't understand : "The code in that thread is the exact one which you have to resort to when the following code will not work for you.", sorry -_-
thanks for all, specially to Sean
n-l-i-d: i'm too busy to read it now, but first line are interested  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Fri Apr 03, 2009 10:17 am Post subject: |
|
|
| enigmatiqk wrote: | | its ok if i want create a method in com.ahk | No, you didn't/don't need new functions. Just call COM_Error(0), afterwards no error message box will ever pop up.
| Code: | | stockSheet := COM_Invoke(WorkBook, "Sheets.Add", "-0", "+" COM_Invoke(WorkBook, "Sheets", COM_Invoke(WorkBook, "Sheets.Count"))) | Just use/adopt this code to your need. Yes, this code will add a new sheet after the last one. Move is similar.
| Code: | COM_Invoke(Workbook, "Sheets('Data').Move", "+" COM_Invoke(Workbook, "Sheets", 1)) ; Before
COM_Invoke(Workbook, "Sheets('Data').Move", "-0", "+" COM_Invoke(Workbook, "Sheets", COM_Invoke(Workbook, "Sheets.Count"))) ; After
|
|
|
| Back to top |
|
 |
enigmatiqk
Joined: 13 Apr 2007 Posts: 28
|
Posted: Fri Apr 03, 2009 12:06 pm Post subject: |
|
|
thank you, all works fine now
i haved updated my last message with excel.com.ahk added code.
[EDIT]
oh ! , i don't understand param "-0" would mean
and about "+", i know the COM.AHK post:
| Quote: | There are some occasions where another COM Object ObjPrm should be a parameter. In that case, prefix it with "+" like:
Code:
COM_Invoke(Object, "Function", "+" . ObjPrm) ; never directly prefix it like +ObjPrm. |
but i don't see the difference with "+" or without "+", can you have a simple method un vbs/vba and the adapter method un ahk (with "+") please?
[/EDIT]
[EDIT]
i have found how change font style:
Style have been test with bold and italic (if you use bold then italic, the text will be bold-italic)
Excel_StyleFont("A", 1, "Bold",1) set Bold = true
Excel_StyleFont("A", 1, "Bold",0) set Bold = false
Excel_StyleFont("A", 1, "Bold",?) i don't know if the fourth param can have other value
| Code: | ; put param=1 set Style = true, param=2 set Style = false
Excel_StyleFont(ColumnLetter, RowNumber, Style,param){
if !oExcel := COM_GetActiveObject("Excel.Application") { ; Get the Already Running Instance
MsgBox Could not find Excel Instance.
Return
}
;Get the cell range
if !oCells := COM_Invoke(oExcel,"Cells",RowNumber,Excel_GetColumnIndex(ColumnLetter)) {
MsgBox Could not get cell range.
Return
}
oFont := COM_Invoke(oCells,"Font")
COM_Invoke(oFont,Style,param)
COM_Release(oFont)
COM_Release(oCells)
COM_Release(oExcel)
} |
i don't know how change color, color function show error msg
and its the same if i try to change background color of a cell ("Interior")
[/EDIT] |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Fri Apr 03, 2009 1:59 pm Post subject: |
|
|
| enigmatiqk wrote: | | but i don't see the difference with "+" or without "+", can you have a simple method un vbs/vba and the adapter method un ahk (with "+") please? | Without the prefix "+", the numeric parameter will be interpreted just as a 32-bit integer, not as an object.
For example, "0" will be just an integer zero, "+0" will be Nothing in VB. BTW, "-0" will be NULL in VB.
I suppose now you got the picture needed to code with COM_Invoke(). |
|
| Back to top |
|
 |
enigmatiqk
Joined: 13 Apr 2007 Posts: 28
|
Posted: Fri Apr 03, 2009 3:20 pm Post subject: |
|
|
thanks
but i don't found how i can change the background color
functions color, background, color-background isn't known
[EDIT]
i have found it:
to change background color:
Excel_StyleCell("A", 1, "Color","AB12F5")
| Code: | Excel_StyleCell(ColumnLetter, RowNumber, Style,param){
if !oExcel := COM_GetActiveObject("Excel.Application") { ; Get the Already Running Instance
MsgBox Could not find Excel Instance.
Return
}
;Get the cell range
if !oCells := COM_Invoke(oExcel,"Cells",RowNumber,Excel_GetColumnIndex(ColumnLetter)) {
MsgBox Could not get cell range.
Return
}
IfInString,Style,Color
{
hex = 0x%param%
SetFormat, integer, d
hex -= 0
}
oInterior := COM_Invoke(oCells,"Interior")
COM_Invoke(oInterior,"Color",hex)
COM_Release(oInterior)
COM_Release(oCells)
COM_Release(oExcel)
} |
[/EDIT] |
|
| Back to top |
|
 |
hughman
Joined: 11 Feb 2007 Posts: 166
|
Posted: Thu Apr 16, 2009 10:44 am Post subject: |
|
|
| Code: |
ActiveWorkbook.Saveas Filename="C:\list.txt" Format="xlText"
|
How to convert the VBA code like above to COM expression? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
|
| Back to top |
|
 |
hughman
Joined: 11 Feb 2007 Posts: 166
|
Posted: Thu Apr 16, 2009 3:27 pm Post subject: |
|
|
Thx. That's the Excel macro I copied.
According to the msdn
| Code: | | COM_Invoke(oWorkbook, "SaveAs", "C:\1.txt") |
This can saveas correctly. But I have to change the file format, so I write:
| Code: | | COM_Invoke(oWorkbook, "SaveAs", "C:\1.txt", "xlText") |
It throw a error. why?
MSDN syntax:
expression.SaveAs(Filename,FileFormat,Password,WriteResPassword,ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru,TextCodePage, TextVisualLayout)
My code:
| Code: |
COM_Init()
oExcel := COM_CreateObject("Excel.Application")
COM_Invoke(oExcel,"Visible=",True)
oWorkbook := COM_Invoke(oExcel,"Workbooks.Open", "C:\1.xls")
COM_Invoke(oWorkbook, "SaveAs", "C:\1.txt", "xlText")
COM_Release(oWorkbook)
COM_Release(oExcel)
COM_Term()
|
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Apr 16, 2009 11:01 pm Post subject: |
|
|
| hughman wrote: | But I have to change the file format, so I write:
| Code: | | COM_Invoke(oWorkbook, "SaveAs", "C:\1.txt", "xlText") | It throw a error. why? |
You have to use a number for that: XlFileFormat.
| Code: | | COM_Invoke(oWorkbook, "SaveAs", "C:\1.txt", -4158) ; xlCurrentPlatformText |
|
|
| Back to top |
|
 |
christopher_rath
Joined: 11 Jun 2009 Posts: 4 Location: Ottawa, Canada
|
Posted: Thu Jun 11, 2009 12:19 am Post subject: Outlook VBA & message window |
|
|
I would like to use AutoHotKey to run some VBA in Outlook. From searching this forum it looks like the best way to do this is through use of the COM library. My initial problem, as I look to try and write some AHK code to do this is that I'm not sure how to determine that a message window has focus before I execute the VBA. Any suggestion?
Thanks,
Christopher |
|
| Back to top |
|
 |
Astrognaw
Joined: 27 Mar 2009 Posts: 26
|
Posted: Mon Aug 10, 2009 9:38 pm Post subject: |
|
|
| Thank you for these! Any plans on finishing the Access functions? I'd be grateful! |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Mon Aug 10, 2009 9:45 pm Post subject: Re: Outlook VBA & message window |
|
|
| christopher_rath wrote: | I would like to use AutoHotKey to run some VBA in Outlook. From searching this forum it looks like the best way to do this is through use of the COM library. My initial problem, as I look to try and write some AHK code to do this is that I'm not sure how to determine that a message window has focus before I execute the VBA. Any suggestion?
Thanks,
Christopher | I cant imagine many peices of VBA that require focus in relation to Outlook but setting focus would depend entirely on what your setting focus on
@ Astrognaw look up ADO in the forum _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Mon Aug 10, 2009 11:33 pm Post subject: |
|
|
| If you're determined to do through COM.ahk, you may consider to do the job entirely in it, i.e., may translate the VBA code into AHK. |
|
| Back to top |
|
 |
Question Guest
|
Posted: Fri Aug 14, 2009 4:58 pm Post subject: |
|
|
| Is there any way to retrieve the pattern color from a cell in excel? |
|
| Back to top |
|
 |
HeWhoWas
Joined: 03 Aug 2009 Posts: 86 Location: Australia (Sydney)
|
Posted: Sat Aug 15, 2009 6:24 am Post subject: |
|
|
I think Cells.Interior.ColorIndex will return the colour currently filling the cell. _________________ There are 10 kinds of people in the world. Those who understand binary and those who don't. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|