Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set filename word document
#1
Hi All,

Is it possible to create a word document with a filename? I like to create a filename like this: is search for a value (string) which contains eg. 99-88-65 and add something like "document" after it, so the word document had to be named: string_document and this will be as the example: 99-88-65_document

Further in the macro i would like to check if this document is open and continue with it.

Can this be done?
And please help me with an example if it's possible

Greetings

Sonic
#2
Where to search? If it is a string or a list of strings, please post it.
#3
Hi,

I extract this from another program.

So i have the sting called unique with the data i mentioned.

Grz
#4
Macro Macro1991
Code:
Copy      Help
str unique="99-88-65"
str fileName=F"{unique}_document.doc"
int w=win(F"{fileName} - Microsoft Word" "OpusApp" "" 1)
if w
,out "yes"
else
,out "no"
#5
Thanks,

one more question if i may....

If the document hasn't that name, how to give it that name? So Word sets the filename to the active document?

TIA
#6
Macro Macro1991
Code:
Copy      Help
;/exe 1
typelib Word {00020905-0000-0000-C000-000000000046} 8.0

str unique="99-88-65"
str fileName=F"{unique}_document.doc"
int w=win(F"{fileName} - Microsoft Word" "OpusApp" "" 1)
if w
,out "yes"
else
,out "no"
,run "WINWORD.EXE" "" "" "" 0x800 win(" - Microsoft Word" "OpusApp") w
,Word.Application app._getactive
,VARIANT v=_s.expandpath(F"$documents$\{fileName}")
,app.ActiveDocument.SaveAs(v)
#7
if problems with type library

Macro Macro1991
Code:
Copy      Help
;/exe 1
str unique="99-88-65"
str fileName=F"{unique}_document.doc"
int w=win(F"{fileName} - Microsoft Word" "OpusApp" "" 1)
if w
,out "yes"
else
,out "no"
,run "WINWORD.EXE" "" "" "" 0x800 win(" - Microsoft Word" "OpusApp") w
,IDispatch app._getactive("Word.Application")
,VARIANT v=_s.expandpath(F"$documents$\{fileName}")
,app.ActiveDocument.SaveAs(v)
#8
Thank you so much!
#9
But i tested the first macro,

When an empty document was created, it correctly says it doesn't exist and gives the filename.
The second time with the same document (which was named) it also say's the document is not found?

Am i doing something wrong or is the check not correct?

Sonic
#10
With win, window name and class may be different in your Word version.
#11
When i search for the active window it says:

win("99-88-65_document - Microsoft Word" "OpusApp")
#12
My Word adds .doc in window name, maybe because Windows Explorer is set to show file extensons.


Forum Jump:


Users browsing this thread: 2 Guest(s)