Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 326

Use powershell to create a word docx and open it [solved]

$
0
0
Hello,
I found a couple good starting places to do this.
This is directly into powershell. line by line it works great:

Code:

@echo offsetlocalset "wordFile=E:\_Poetry 2024\document.docx"echo Set objWord = CreateObject("Word.Application") > CreateWordDoc.vbsecho Set objDoc = objWord.Documents.Add() >> CreateWordDoc.vbsecho objDoc.Content.Text = "Hello, this is a new Word document." >> CreateWordDoc.vbsecho objDoc.SaveAs wordFile >> CreateWordDoc.vbsecho objDoc.Close >> CreateWordDoc.vbsecho objWord.Quit >> CreateWordDoc.vbsstart /wait wscript CreateWordDoc.vbs -noconsoleendlocal
The word document is created quietly, but I falter on opening it.
So using rainmeter to do the above is a bit past my ability. Along with the opening of the created docx.

There is a bat file option as well. I'm a bit better at using bat files but not quite enough.

I got this from an example online:

Code:

@echo offsetlocalset "wordFile=E:\_Poetry 2024\document.docx"echo Set objWord = CreateObject("Word.Application") > CreateWordDoc.vbsecho Set objDoc = objWord.Documents.Add() >> CreateWordDoc.vbsecho objDoc.Content.Text = "Hello, this is a new Word document." >> CreateWordDoc.vbsecho objDoc.SaveAs wordFile >> CreateWordDoc.vbsecho objDoc.Close >> CreateWordDoc.vbsecho objWord.Quit >> CreateWordDoc.vbsstart /wait wscript CreateWordDoc.vbs -noconsoleendlocal
However it does not really work for my need e.g. the new word.docx does not get created. :confused:

Thanks for any help is welcome.

Statistics: Posted by CodeCode — Yesterday, 5:00 pm — Replies 2 — Views 60



Viewing all articles
Browse latest Browse all 326

Trending Articles