AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MS Office Automation Functions (via COM) [thanks Sean]
Goto page Previous  1, 2, 3 ... 14, 15, 16 ... 18, 19, 20  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  

Should this be continued?
Yes
93%
 93%  [ 14 ]
No
6%
 6%  [ 1 ]
Total Votes : 15

Author Message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Fri Mar 12, 2010 3:27 pm    Post subject: Reply with quote

IMO, it used too much [] syntax, which may be unnecessarily confusing. The following typical syntax are enough.
Code:
xl.Visible := True
oCell := xl.Cells(RowNumber, Excel_GetColumnIndex(ColumnLetter))
...
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Fri Mar 12, 2010 3:36 pm    Post subject: Reply with quote

I guess I still don't understand the difference between the [] and () syntax in that manner. Is it slower to use []?
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Fri Mar 12, 2010 3:50 pm    Post subject: Reply with quote

Strictly speaking, the two are different, however, with COM_L there is no difference between the following two.
Code:
x.y(z)
x.y[z]


OTOH, what I was talking about was not the above, but about the following.
Code:
x.y(z) ; x.y[z]
x["y", z]
The two are equivalent with COM_L, however, the fore is the typical and thus the recommended one.

Last edited by Sean on Fri Mar 12, 2010 3:56 pm; edited 1 time in total
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Fri Mar 12, 2010 3:55 pm    Post subject: Reply with quote

I kind of figured that's what you were getting at once I looked at it again, I'm updating the functions now.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
garysch37



Joined: 04 Mar 2010
Posts: 4
Location: Niagara Falls, Canada

PostPosted: Fri Mar 26, 2010 6:52 pm    Post subject: MS Access Reply with quote

I haven't found any answers here on Microsoft Access support? I know about the existence of ADO COM. But I'm looking specifically about how to click buttons, enter text into text boxes, etc. on Forms.

The AHK Window Spy does not differentiate the controls in an Access Form. Even clicking coordinates won't work because the "window" that a Form is in is not recognized as a window by Window Spy. So instead of the coordinates on a Form being relative to the Form's window, they are instead relative to the overall MS Access window. So if a user moves the Form's window, Window Spy shows the coordinates as changed.

The minimal solution I can think of is to maximize the Form's window when it's opened using VBA:

Code:
Private Sub Form_Open(Cancel As Integer)
   DoCmd.Maximize
   '...etc.
End Sub


Then we'd at least be able to click coordinates, since the relative coordinates of objects on the Form will then be the same as those relative to the main Access window.

But I'd prefer to have AHK control of the objects on a Microsoft Access Form--perhaps similar to what using HTML DOM in AHK did for the objects on a webpage. Does it exist already and I just missed it?

Thanks,
Gary
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Mar 27, 2010 1:07 am    Post subject: Re: MS Access Reply with quote

garysch37 wrote:
But I'd prefer to have AHK control of the objects on a Microsoft Access Form--perhaps similar to what using HTML DOM in AHK did for the objects on a webpage. Does it exist already and I just missed it?
No, looks like few members are interested in automating Access, but, it doesn't stop you digging it yourself. I'm almost sure that it's possible, at least with Office 2003.
Back to top
View user's profile Send private message
ruespe*
Guest





PostPosted: Mon Mar 29, 2010 9:19 am    Post subject: Re: MS Access Reply with quote

garysch37 wrote:
The AHK Window Spy does not differentiate the controls in an Access Form.
Yes, it does. WindowSpy does show you the ClassNN of the Control. With ControlGetPos you can look for the position of the Control within the Access-Window and with ControlClick/ControlSend you can Send commands.
Back to top
Tyrsius



Joined: 09 Jul 2009
Posts: 140

PostPosted: Mon Mar 29, 2010 10:52 pm    Post subject: Reply with quote

Is there an equivalent for Excel to the IE Readystate check? I want to Save a spreadsheet midway through operation, and wait until its done saving before I continue.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Tue Mar 30, 2010 12:34 am    Post subject: Reply with quote

Tyrsius wrote:
Is there an equivalent for Excel to the IE Readystate check? I want to Save a spreadsheet midway through operation, and wait until its done saving before I continue.
Have you confirmed that Excel continues before saving is completed, or, was it just your assumption?
Back to top
View user's profile Send private message
drop4nme



Joined: 18 Jan 2010
Posts: 10

PostPosted: Tue Mar 30, 2010 2:06 am    Post subject: Document Poroperties/Print Reply with quote

using COM, what is the equivalent command to get the number of pages in a word document i.e

Like the following in visual basic:
Code:
ActiveDocument.Content.ComputeStatistics(wdStatisticPages)


Also to print a page range ?
Back to top
View user's profile Send private message
Tyrsius



Joined: 09 Jul 2009
Posts: 140

PostPosted: Tue Mar 30, 2010 2:07 am    Post subject: Reply with quote

Sean wrote:
Tyrsius wrote:
Is there an equivalent for Excel to the IE Readystate check? I want to Save a spreadsheet midway through operation, and wait until its done saving before I continue.
Have you confirmed that Excel continues before saving is completed, or, was it just your assumption?


It actually causes code that tries to execute while Excel saving to just not get executed (skipped), which means it will pick up in the middle of the next operation. I am only looking for the answer because I had a problem.

I could use a sleep, but then I am possibly not waiting long enough, or waiting much longer than I need to.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Tue Mar 30, 2010 3:58 am    Post subject: Reply with quote

the save method does halt the thread until it completes if your code "magically" skips lines its due to a logic error. something in your code is causing this not related to the save

since you didnt post your code we are helpless to do other than point out this obvious fact
_________________

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
View user's profile Send private message
Tyrsius



Joined: 09 Jul 2009
Posts: 140

PostPosted: Tue Mar 30, 2010 4:17 am    Post subject: Reply with quote

Code:
COM_Invoke(pxlb, "Save")


Wow, how did I miss that?

I was using a different (not COM) method of saving the workbook, which did not wait for it to finish saving. I hadn't seen that line when reading the front page the first time, and there isn't a reference to it anywhere else in the thread (probably because it works perfectly), so after reading through 14 pages and not finding anything I asked.

Thanks for pointing me in the right direction Smile
Back to top
View user's profile Send private message
Tyrsius



Joined: 09 Jul 2009
Posts: 140

PostPosted: Thu Apr 01, 2010 8:28 pm    Post subject: Reply with quote

I am having an issue with the save method, but it only occurs when opening an existing file, not when starting a new one. When trying to save I get the error "A file named RESUME.XLW already exists in this location. Do you want to replace it?"

The file was not named RESUME before, but RESUME.XLW gets created in my Documents folder after saving. It does still save the file I am trying to save as well though. Whats going on?

Code:

COM_Init()
oExcel := COM_GetActiveObject("Excel.Application")
COM_Invoke(oExcel, "Save")
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Fri Apr 02, 2010 1:39 am    Post subject: Reply with quote

Compare the previous and the current call. The answer lies there.
BTW, when you're asking a question better post the whole/exact code. Don't assume anything on your own, like whether it's relevant or not.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 14, 15, 16 ... 18, 19, 20  Next
Page 15 of 20

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group