AutoHotkey Community

It is currently May 27th, 2012, 4:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: March 9th, 2010, 7:47 am 
Offline

Joined: March 9th, 2010, 7:28 am
Posts: 1
Hello, I am trying to automate creating a word document that is named "2010-03-08 - Doe John.doc". Then it will open that document and input a template of text. I have this so far, but after inputbox comes up, the explorer folder I am in changes behind the text box to the desktop in an explorer window; so the file created is put on the desktop. I need it to be created in the folder I start the script in.

Here is what I have:
Code:
:*:snn ::
InputBox, UserInput, Client Name, Please enter the Business Name or Client Name., , 340, 180
Send {Alt Down}{f}{Alt Up}
Send W
Send M
Send {Enter}
FormatTime, MyTime,,yyyy-MM-dd
sendInput %MyTime% - .doc
Send {Left}{Left}{Left}{Left}
SendInput %UserInput%
Send {Enter}
Sleep, 1000
Send {Enter}
Sleep, 5000
sendInput ___________________________________________________
send {enter}
FormatTime, TimeString
sendInput Service Notes started today at %TimeString% for %UserInput%.
send {space}
send {enter}
sendInput ___________________________________________________
send {enter}
Return ;Exit


Also, I'm very new; so any major changess or comlete re-write is will not hurt my feelings. Thanks for all your help!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 9:22 am 
Regardless that Desktop is used as the default file destination it's possible to set a path at the edit field of the an SaveAs dialog and it should save the file at your favorite target destination.

Another option (AFAIK) is to change the registry to open a dialog with another default destination. But that might be over the top here.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 7:23 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Prolly not newbie friendly, but here's an example using COM ( AHKL & COM_L ):
Code:
:*:snn ::
InputBox, UserInput, Client Name, Please enter the Business Name or Client Name., , 340, 180
FormatTime, MyTime,,yyyy-MM-dd
oWord := COM_CreateObject( "Word.Application" )
oWord.Visible := True
oDoc := oWord.Documents.Add()
oDoc.SaveAs( A_ScriptDir "\" MyTime ".doc" )
FormatTime, TimeString
text :=   "___________________________________________________`n"
      .   "Service Notes started today at " TimeString " for " UserInput ". `n"
      .   "___________________________________________________`n"
oWord.Selection.TypeText( text )
Return ;Exit

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 7:56 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
More newbie friendly:
Code:
inputbox, fn
text =
(
This is a template
...
...
end
)
fileappend, %text%, %a_scriptdir%\%fn%.doc
run, %a_scriptdir%\%fn%.doc

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 8:05 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
flyingDman wrote:
More newbie friendly...


This causes a string of the same error message for me, even though it eventually opens the doc:

Error message wrote:
Word cannot start the converter mswrd632.wpc

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 8:10 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
Works for me on Vista and Office 2007. BTW iIt does not work with Excel if a CSV extension is used.
Any luck with a "sleep" between the fileappend and the run?

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 8:13 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
@sinkfaze:

http://www.microsoft.com/communities/ne ... &sloc=&p=1

and

http://blogs.technet.com/wordonenotesup ... files.aspx

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 8:16 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Unfortunately editing the registry is not an option for me. Nonetheless, it opens the doc eventually but the potential for error messages isn't very friendly.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 8:37 pm 
Offline

Joined: February 27th, 2009, 9:11 am
Posts: 693
Location: Burbank, California
Yet another Microsoft quirk ...

_________________
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot], rbrtryn, Yahoo [Bot] and 68 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