| View previous topic :: View next topic |
| Author |
Message |
jarredm007
Joined: 09 Mar 2010 Posts: 1
|
Posted: Tue Mar 09, 2010 6:47 am Post subject: Creating a word doc w/ inputbox value in file name and insid |
|
|
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! |
|
| Back to top |
|
 |
Murx Guest
|
Posted: Tue Mar 09, 2010 8:22 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Tue Mar 09, 2010 6:23 pm Post subject: |
|
|
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 |
_________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
flyingDman
Joined: 27 Feb 2009 Posts: 690 Location: Burbank, California
|
Posted: Tue Mar 09, 2010 6:56 pm Post subject: |
|
|
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... |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Tue Mar 09, 2010 7:05 pm Post subject: |
|
|
| 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 |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
flyingDman
Joined: 27 Feb 2009 Posts: 690 Location: Burbank, California
|
Posted: Tue Mar 09, 2010 7:10 pm Post subject: |
|
|
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... |
|
| Back to top |
|
 |
flyingDman
Joined: 27 Feb 2009 Posts: 690 Location: Burbank, California
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Tue Mar 09, 2010 7:16 pm Post subject: |
|
|
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. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
flyingDman
Joined: 27 Feb 2009 Posts: 690 Location: Burbank, California
|
Posted: Tue Mar 09, 2010 7:37 pm Post subject: |
|
|
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... |
|
| Back to top |
|
 |
|