#102102 - 2003-06-13 04:34 PM
Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
I'm in the process of taking one large file, breaking it up into smaller files based on userid, and pulling each broken file into a template and saving it. I've finished the part where the file is broken based on userid, and I have a template. I can't seem to open word,with an already created document and use a specified template (miscinfo.dot). I've tried the following:
code:
"c:\Program Files\Microsoft Office\Office10\winword.exe" /t"E:\miscinfo.dot"
code:
"e:\invoices\miscinfo\mydoc.doc" /t"E:\MiscInfo.dot"
The first opens word with the template, the second opens the doc, but not the template...
Help.
|
|
Top
|
|
|
|
#102104 - 2003-06-13 04:48 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
Thanks for the QUICK response!!!
The original data is in the main file, although I am able to pull it out and push it into a text file. How would I do an open and save as through kix?
|
|
Top
|
|
|
|
#102105 - 2003-06-13 04:53 PM
Re: Open a created word doc, with a template...
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
there are some posts in the COM forum using WORD and Excel... that would be the way to go.
|
|
Top
|
|
|
|
#102107 - 2003-06-13 04:59 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
Rad, Thanks for the info, I was searching in the scripts, and starters forums so I didn't find anything. I do see many posts in the com forum.
Lonkero, Thanks, I will see exactly what the macro in my document does and try to write kix code from that.
L8tr...
|
|
Top
|
|
|
|
#102109 - 2003-06-13 05:09 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
Shawn, thanks for the suggestion...I tried that, and it didn't open the template, but it opened the file..
|
|
Top
|
|
|
|
#102110 - 2003-06-13 05:14 PM
Re: Open a created word doc, with a template...
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
yeah, i saw same but if you got to "templates and addins" does the template show as loaded ?
[edit]
Heres the link I found:
The link I found [ 13. June 2003, 17:16: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#102111 - 2003-06-13 05:17 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
Yes, the template does show as being loaded, but why can't I see it?
|
|
Top
|
|
|
|
#102112 - 2003-06-13 05:18 PM
Re: Open a created word doc, with a template...
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Thats the million dollar question my friend. I have no idea
|
|
Top
|
|
|
|
#102113 - 2003-06-13 05:21 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
It's good that it loads, but not good that you can't see it... Back to the drawing board...oh yeah, by the way, kixforms rocks!!
|
|
Top
|
|
|
|
#102115 - 2003-06-13 08:17 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
hehehehehehehe.....
|
|
Top
|
|
|
|
#102116 - 2003-06-13 08:51 PM
Re: Open a created word doc, with a template...
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
cmarti
Maybe you can use this.
The following code will attach the template: E:\MiscInfo.dot to the document: E:\invoices\miscinfo\mydoc.doc using the function: ChangeTemplate()
Some strange things to observe: - The document can be protected and the attached template is stil changed. - BUT the template you attach may not be protected ???
So if the template is protected you must unprotect it before running the script, and protect it again when you are finished.
code:
Break On ChangeTemplate("E:\invoices\miscinfo\mydoc.doc","E:\MiscInfo.dot") Function ChangeTemplate($Document,$Template) Dim $oWord $oWord = CreateObject('Word.Application') $RC = $oWord.Documents.Open($Document) $oWord.ActiveDocument.AttachedTemplate = $Template $oWord.ActiveDocument.Save $oWord.Application.Quit(0) EndFunction
-Erik [ 13. June 2003, 21:15: Message edited by: kholm ]
|
|
Top
|
|
|
|
#102117 - 2003-06-13 09:22 PM
Re: Open a created word doc, with a template...
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
Nice try Erik but did not work for me.
Maybe cmarti will have better luck with it.
Microsoft Knowledge Base Article - 210565 Word Startup (Command-Line) Switches and Their Purpose http://support.microsoft.com/default.aspx?scid=kb;EN-US;210565
What you should be able to do is open the document, then select all, copy, open template, paste, save-as %n%.doc
|
|
Top
|
|
|
|
#102118 - 2003-06-13 09:39 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
NTDoc, Thanks for the path, I've actually already looked at that kb article. I can open word, it just doesn't open the template.
Kholm, I'll try your code and see how it works for me.
The response from this board is always great...
Thanks..
|
|
Top
|
|
|
|
#102119 - 2003-06-13 09:49 PM
Re: Open a created word doc, with a template...
|
cmarti
Hey THIS is FUN
Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
|
Kholm, The code opened the document, but it didn't change the template....
|
|
Top
|
|
|
|
#102121 - 2003-06-13 11:01 PM
Re: Open a created word doc, with a template...
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
cmarti,
This code is VERY close to working. Not quite, but close.
What I "think" is happening is that the DOC1.DOC is open, copies data, but then never switches to the .DOT Then does a Save-AS to DOC4.DOC from DOC1.DOC
Maybe someone else can work on it with you. I don't have any more time today to look at it.
code:
break on ChangeTemplate("C:\Temp\test1.doc","C:\Temp\miscinfo.dot") Function ChangeTemplate($Document,$Template) Dim $oWord $oWord = CreateObject('Word.Application') $RC = $oWord.Documents.Open($Template) $RC = $oWord.Documents.Open($Document) $oWord.Selection.WholeStory $oWord.Selection.Copy $oWord.ActiveDocument = $Template $oWord.Selection.PasteAndFormat("wdPasteDefault") $oWord.ChangeFileOpenDirectory("C:\temp\") $oWord.ActiveDocument.SaveAs("Doc4.doc", 0) $oWord.Application.Quit(0) EndFunction
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 483 anonymous users online.
|
|
|