AutoHotkey Community

It is currently May 27th, 2012, 1:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 296 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20

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: January 5th, 2011, 4:54 pm 
Offline

Joined: July 13th, 2010, 3:56 pm
Posts: 10
tank wrote:
ApertureLabs wrote:
Also getting this error. Any luck on resolving it?
What makes any of you think document is a member of the application?
why else would you be getting this error

http://msdn.microsoft.com/en-us/library/bb255823.aspx


Because the code we used was listed as sample code in the first post of this thread.

Worked around it by only grabbing the functions I needed. And then gutting the pure COM_Invoke commands from them.

My new problem is printing with Word. Because the printout method has over 9 parameters, I was wondering if there was a way to do something like this:
Code:
ActiveDocument.ActiveWindow.PrintOut _
    Range:=wdPrintFromTo, From:="1", To:="3"

and be able to set parameters you need that are at the end of the method, because this is how long the printout method is:

Code:
PrintOut(Background, Append, Range, OutputFileName, From, To, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX, ManualDuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 5:17 pm 
ApertureLabs wrote:
Worked around it by only grabbing the functions I needed. And then gutting the pure COM_Invoke commands from them.
:D - it's great to see ppl who can figure that out for themselves :wink:

Code:
wdPrintFromTo := 3
Com_Invoke(oWord, "ActiveDocument.ActiveWindow.Printout", "-0", "-0", wdPrintFromTo, "-0", From:="1", To:="3")


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 5:50 pm 
Offline

Joined: July 13th, 2010, 3:56 pm
Posts: 10
a4u wrote:
ApertureLabs wrote:
Worked around it by only grabbing the functions I needed. And then gutting the pure COM_Invoke commands from them.
:D - it's great to see ppl who can figure that out for themselves :wink:

Code:
wdPrintFromTo := 3
Com_Invoke(oWord, "ActiveDocument.ActiveWindow.Printout", "-0", "-0", wdPrintFromTo, "-0", From:="1", To:="3")


Sorry, not quite what I meant. I need to set PrintToFile, which is beyond the 9 parameter limit. Is it possible to use that format I posted, to only set certain parameters?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 6:12 pm 
Well, you have three options:
  • modify Com_Invoke to accept more parameters
  • Use AutoHotkey_L & COM_L:
    Code:
    ; untested
    oWord.AcitiveDocument.ActiveWindow.Printout(Com_Parameter("OutputFileName","<Full File Name>", Com_Parameter("PrintToFile", True))
  • Use AutoHotkey_L COM Natively (recommended):
    Code:
    ; Untested
    m := ComObjMissing()
    oWord.AcitiveDocument.ActiveWindow.PrintOut(m, m, m, "<Full File Name>", m, m, m, m, m, m, True)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2011, 6:23 pm 
Offline

Joined: July 13th, 2010, 3:56 pm
Posts: 10
a4u wrote:
Well, you have three options:
  • modify Com_Invoke to accept more parameters
  • Use AutoHotkey_L & COM_L:
    Code:
    ; untested
    oWord.AcitiveDocument.ActiveWindow.Printout(Com_Parameter("OutputFileName","<Full File Name>", Com_Parameter("PrintToFile", True))
  • Use AutoHotkey_L COM Natively (recommended):
    Code:
    ; Untested
    m := ComObjMissing()
    oWord.AcitiveDocument.ActiveWindow.PrintOut(m, m, m, "<Full File Name>", m, m, m, m, m, m, True)


Either of the AutoHotKey_L options means rewriting most of the COM in my script (or include 2 libraries with my script).

Is it at all possible to modify COM_Invoke to accept more parameters?
I had tried to do it long ago, but gave up.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2011, 5:25 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
Hey everyone. I'm tring to dig into this a lot more now and see what I can do. I'm having a little trouble getting started. I'm starting with Word.

I have added the library Word.ahk to my default library. When I try the following:

Code:
; WORD TEST SCRIPT
com_CoInitialize() ; Initialize COM

; File Name to be created / opened
FileName = test_word_document.doc

Word_Open() ; Opens a New Document
; Word_OpenDoc(FileName) ; Opens an existing document

com_CoUnInitialize()
exitapp


I receive this error:

Code:
---------------------------
QuickAHK_RunScript.ahk
---------------------------
Error in #include file "C:\Users\v-jerfis\Documents\AutoHotkey\Lib\Word.ahk": Call to nonexistent function.

Specifically: UUID() . "]"

   Line#
   313: COM_Invoke(ObjWord,"Activate") 
   314: }
   315: Return,ObjWord
   316: }
   336: {
   337: DetectHiddenWindows,On
   338: SetTitleMatchMode,2
--->   341: sCaption := "[" . UUID() . "]"
   343: com_invoke(hObj,"Caption=",sCaption) 
   345: sCaption := com_invoke(hObj,"Caption")
   346: if !hWnd := WinExist(sCaption) 
   347: MsgBox,No Window Could Be found!
hWnd: %hWnd%
sCaption: %sCaption%
   349: com_invoke(hObj,"Caption=","") 
   350: Return,hWnd
   351: }

The program will exit.
---------------------------
OK   
---------------------------


Can anyone offer some assistance or should I post in the Ask for Help?

_________________
-Jeremiah


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2011, 5:33 pm 
I believe this is the UUID() function.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2011, 5:52 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
Thank you a4u!

That opens the instance of Word, but now I'm getting this once it's opened.
Code:
---------------------------
COM Error Notification
---------------------------
Function Name:   "Select"
ERROR:   Unknown name.

   (0x80020006)

Will Continue?
---------------------------
Yes   No   
---------------------------

_________________
-Jeremiah


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2011, 6:17 pm 
Hopefully it's already been discussed in this thread, but there's an error in the Word_Open() function. Here's a modified version:
Code:
Word_Open(){
   Word := Word_Attach("N") ; Attach to New Window
   Documents := com_Invoke(Word, "Documents")
   Doc := com_invoke(Documents,"Add") ;    Add a new document
   com_invoke(Doc,"Select") ; Select it
   com_release(Doc) ; cleanup
   com_release(Documents) ; cleanup
   com_release(Word) ; cleanup
   }


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2011, 6:42 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
Awesome! Thank you very much!

I'm not sure if it's been talked about yet, sorry if it was.

_________________
-Jeremiah


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 25th, 2012, 9:39 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
I know this thread is older than dirt
but one easy way to deal with excel columns...
I took what i was doing in vba and just translated it over
I'm sure there are probably better solutions

below is just an excerpt from one of my scripts where I'm parsing results from sql

Code:
Loop, Parse, A_Result, `r
{
   LineData := A_LoopField
   ColInd := Excel_GetColumnIndex(StartCol)

   Loop, Parse, LineData, %A_Tab%
   {
      If (ColInd > 26)
         OutCol := Chr(((ColInd - 1) / 26) + 64) . Chr(Mod((ColInd - 1), 26) + 65)
      else
         OutCol := Chr(ColInd + 64)

      Excel_SetText(OutCol, RowNum, A_LoopField)
      ColInd+=1
   }
   
   RowNum+=1
}


Edit: Updated code to better accomade columsn with double letters.. I forgot about them ><

_________________
Neil
www.delta3d.com


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 ... 16, 17, 18, 19, 20

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Bon, sks and 17 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