Code: Select all
oWord := ComObjCreate("Word.Application")
oWord.Documents.Add
"Mytitle" document. Is it possible?
Code: Select all
oWord := ComObjCreate("Word.Application")
oWord.Documents.Add
Yeah I've read that one and it's from there I am creating my script. But can't seem to find how to name a doc upon creating it. Neither did I find anything useful on MSDN.BoBo wrote:Let's guess yes: https://autohotkey.com/boards/viewtopic.php?t=8978
That's a bummer, yeah I guess I need to create a file first. Thanks!jeeswg wrote:- Usually Word gives you a temporary document name, otherwise you give it a name when you save it.
- I wouldn't expect that you can change the temporary name, maybe you can.
- A workaround would be to create a blank file with a specific filename.
Code: Select all
q:: ;word - try to change name (doesn't work)
oWd := ComObjCreate("Word.Application")
oWd.Visible := -1 ;True
oWd.Documents.Add
MsgBox, % oWd.ActiveDocument.Name ;Document1
oWd.ActiveDocument.Name := "New Name" ;doesn't work
;error: 'Name' is a read only property.
MsgBox, % oWd.ActiveDocument.Name ;Document1
oWd := ""
return
Code: Select all
w:: ;word - open/save a file
vPath := A_Desktop "\z word temp 1.docx"
vPath2 := A_Desktop "\z word temp 2.docx"
if !FileExist(vPath)
return
oWd := ComObjCreate("Word.Application")
oWd.Visible := -1 ;True
oWd.Documents.Open(vPath)
MsgBox, % oWd.ActiveDocument.Name ;z word temp 1.docx
if !FileExist(vPath2)
oWd.ActiveDocument.SaveAs(vPath2)
oWd := ""
return
Of course not eg. it's Dokument1 in German.- For me it creates 'Document1', is that the same for other languages?
Users browsing this forum: No registered users and 242 guests