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 

Creating a word doc w/ inputbox value in file name and insid

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jarredm007



Joined: 09 Mar 2010
Posts: 1

PostPosted: Tue Mar 09, 2010 6:47 am    Post subject: Creating a word doc w/ inputbox value in file name and insid Reply with quote

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





PostPosted: Tue Mar 09, 2010 8:22 am    Post subject: Reply with quote

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

PostPosted: Tue Mar 09, 2010 6:23 pm    Post subject: Reply with quote

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

_________________
Very Happy - in case I forgot to smile
Basic Webpage Controls
COM Object Reference
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
flyingDman



Joined: 27 Feb 2009
Posts: 690
Location: Burbank, California

PostPosted: Tue Mar 09, 2010 6:56 pm    Post subject: Reply with quote

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



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

PostPosted: Tue Mar 09, 2010 7:05 pm    Post subject: Reply with quote

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



Joined: 27 Feb 2009
Posts: 690
Location: Burbank, California

PostPosted: Tue Mar 09, 2010 7:10 pm    Post subject: Reply with quote

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



Joined: 27 Feb 2009
Posts: 690
Location: Burbank, California

PostPosted: Tue Mar 09, 2010 7:13 pm    Post subject: Reply with quote

@sinkfaze:

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.word.application.errors&tid=28597190-67e9-46f2-9d46-4e4e3f041f6b&cat=&lang=&cr=&sloc=&p=1

and

http://blogs.technet.com/wordonenotesupport/archive/2009/12/10/when-opening-the-word-document-users-are-getting-error-word-cannot-start-the-convertor-mswrd632-wpc-or-cannot-load-word-for-windows-6-0-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...
Back to top
View user's profile Send private message
sinkfaze



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

PostPosted: Tue Mar 09, 2010 7:16 pm    Post subject: Reply with quote

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



Joined: 27 Feb 2009
Posts: 690
Location: Burbank, California

PostPosted: Tue Mar 09, 2010 7:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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