AutoHotkey Community

It is currently May 26th, 2012, 5:28 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 296 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 20  Next

Should this be continued?
Poll ended at June 18th, 2008, 11:34 pm
Yes 93%  93%  [ 14 ]
No 7%  7%  [ 1 ]
Total votes : 15
Author Message
 Post subject:
PostPosted: April 3rd, 2009, 10:30 am 
Offline

Joined: April 13th, 2007, 8:28 am
Posts: 28
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

Sean wrote:
Code:
Set stockSheet = workBook.Sheets.Add( , workBook.Sheets(workBook.Sheets.Count))
I already explained it here:
http://www.autohotkey.com/forum/viewtop ... 5&start=75


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 :) :D :D :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2009, 11:17 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2009, 1:06 pm 
Offline

Joined: April 13th, 2007, 8:28 am
Posts: 28
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2009, 2:59 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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().


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 3rd, 2009, 4:20 pm 
Offline

Joined: April 13th, 2007, 8:28 am
Posts: 28
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2009, 11:44 am 
Offline

Joined: February 11th, 2007, 4:10 pm
Posts: 185
Code:
ActiveWorkbook.Saveas Filename="C:\list.txt" Format="xlText"


How to convert the VBA code like above to COM expression?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2009, 3:26 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
hughman wrote:
Code:
ActiveWorkbook.Saveas Filename="C:\list.txt" Format="xlText"
Is it correct? Anyway read the documentation, all are there.
http://msdn.microsoft.com/en-us/library/bb214129.aspx


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2009, 4:27 pm 
Offline

Joined: February 11th, 2007, 4:10 pm
Posts: 185
Sean wrote:
Is it correct? Anyway read the documentation, all are there.
http://msdn.microsoft.com/en-us/library/bb214129.aspx


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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2009, 12:01 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 11th, 2009, 1:19 am 
Offline

Joined: June 11th, 2009, 1:14 am
Posts: 4
Location: Ottawa, Canada
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2009, 10:38 pm 
Offline

Joined: March 27th, 2009, 1:00 am
Posts: 26
Thank you for these! Any plans on finishing the Access functions? I'd be grateful!


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 10th, 2009, 10:45 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
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

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 11th, 2009, 12:33 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2009, 5:58 pm 
Is there any way to retrieve the pattern color from a cell in excel?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2009, 7:24 am 
Offline

Joined: August 3rd, 2009, 9:20 am
Posts: 85
Location: Australia (Sydney)
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 296 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 20  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, XX0 and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group