![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | a stupid question on word.application Hi, I am trying to implement a vb script to converting old files automatically. I decided to use vbscript, but I am new to this scripting language. I can not call the documents.open method and pass to it the Format and ConfirmConversions properties. How is the correct syntax? On web I fin only the simplest call: objWord.Documents.Open(filename). I tried as: objWord.Documents.Open(filename, ConfirmConversions=False, Format=fmt), but this gave me errors of type object. Where I miss something? thanks Gianluca |
My System Specs![]() |
| | #2 (permalink) |
| | Re: a stupid question on word.application "gianbrix" <---***gilucasa***---@xxxxxx> wrote in message news:X7tul.283953$FR.580278@xxxxxx Quote: > Hi, > I am trying to implement a vb script to converting old files > automatically. > I decided to use vbscript, but I am new to this scripting language. > I can not call the documents.open method and pass to it the Format and > ConfirmConversions properties. > How is the correct syntax? > On web I fin only the simplest call: > objWord.Documents.Open(filename). > I tried as: > objWord.Documents.Open(filename, ConfirmConversions=False, Format=fmt), > but this gave me errors of type object. > Where I miss something? > thanks http://msdn.microsoft.com/en-us/library/bb216319.aspx -Paul Randall |
My System Specs![]() |
| | #3 (permalink) |
| | Re: a stupid question on word.application Il 13/03/2009 15.54, Paul Randall ha scritto: Quote: > You might want to look at the Word Object Model info at msdn.microsoft.com. > http://msdn.microsoft.com/en-us/library/bb216319.aspx I read, but I can not understand this: Documents.Open FileName:="C:\MyFiles\MyDoc.doc", ReadOnly:=True I wrote this, but I get errors: set oDoc = objWord.Documents.Open FileName:=objFile, Format:=fmt is equal in vbscript var:=? is not var=? I am confused ciao Gianluca |
My System Specs![]() |
| | #4 (permalink) |
| | Re: a stupid question on word.application On Mar 13, 10:57*am, gianbrix <---***gilucasa***...@xxxxxx> wrote: Quote: > Il 13/03/2009 15.54, Paul Randall ha scritto: > Quote: > > You might want to look at the Word Object Model info at msdn.microsoft.com. > >http://msdn.microsoft.com/en-us/library/bb216319.aspx > I read, but I can not understand this: > * * *Documents.Open FileName:="C:\MyFiles\MyDoc.doc", ReadOnly:=True > > I wrote this, but I get errors: > > set oDoc = objWord.Documents.Open FileName:=objFile, Format:=fmt > > is equal in vbscript var:=? is not var=? > I am confused > ciao > Gianluca not in VBScript. In scripting, that arguments are determined strictly by their order, not by their names (as can be done in VBA). Just remove the names and it should work ... set oDoc = objWord.Documents.Open("C:\MyFiles\MyDoc.doc", True) Note that the arguments of functions (routines that return a value) must be enclosed in parentheses (while they must NOT have parens for subroutines). If the name of the file is in a variable, just substitute that variable's name, as in ... sFilename = "C:\MyFiles\MyDoc.doc" set oDoc = objWord.Documents.Open(sFilename, True) Also, watch out for the predefined constants. They are not available to scripting, unless you provide them. This is generally done by determining their value in the application and providing it in a CONST statement in the script. HTH, Tom Lavedas ========== |
My System Specs![]() |
| | #5 (permalink) |
| | Re: a stupid question on word.application Il 13/03/2009 17.11, T Lavedas ha scritto: Quote: > On Mar 13, 10:57 am, gianbrix<---***gilucasa***...@xxxxxx> wrote: > determining their value in the application and providing it in a CONST > statement in the script. > > HTH, > > Tom Lavedas ok all is clearer Thanks. Only a question: if the function has for example 10 arguments, and I have to specify the firs and the last, without the possibility to indicate the parameter's name, how can I accomplish that? With the exact numbers of commas in this way?: funcion(fistParam,,,,,,,,,lastParam) bye Gianluca |
My System Specs![]() |
| | #6 (permalink) |
| | Re: a stupid question on word.application On Mar 13, 12:24*pm, gianbrix <---***gilucasa***...@xxxxxx> wrote: Quote: > Il 13/03/2009 17.11, T Lavedas ha scritto: > Quote: > > On Mar 13, 10:57 am, gianbrix<---***gilucasa***...@xxxxxx> *wrote: > > determining their value in the application and providing it in a CONST > > statement in the script. Quote: > > HTH, Quote: > > Tom Lavedas > ok all is clearer Thanks. Only a question: > if the function has for example 10 arguments, and I have to specify the > firs and the last, without the possibility to indicate the parameter's > name, how can I accomplish that? > With the exact numbers of commas in this way?: > > funcion(fistParam,,,,,,,,,lastParam) > > bye > Gianluca Tom Lavedas ========= |
My System Specs![]() |
| | #7 (permalink) |
| | Re: a stupid question on word.application Il 13/03/2009 18.40, T Lavedas ha scritto: Quote: > Yes, that should work. > > Tom Lavedas ok it works fine!! Have you got a suggestion to separate filename form its extension? Is there a dedicated method? I used name=right(FileName, -3), but of course extensions are not alwasy of 3 letters as in ".ws". bye Gianluca |
My System Specs![]() |
| | #8 (permalink) |
| | Re: a stupid question on word.application On Mar 13, 2:58*pm, gianbrix <---***gilucasa***...@xxxxxx> wrote: Quote: > Il 13/03/2009 18.40, T Lavedas ha scritto: > Quote: > > Yes, that should work. Quote: > > Tom Lavedas > ok it works fine!! > Have you got a suggestion to separate filename form its extension? > Is there a dedicated method? > I used > name=right(FileName, -3), but of course extensions are not alwasy of 3 > letters as in ".ws". > bye > > Gianluca Function GetTheBase(filespec) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") GetTheBase = fso.GetBaseName(filespec) End Function See WSH 5.6 documentation download (URL all one line) http://www.microsoft.com/downloads/d...displaylang=en Tom Lavedas ========= |
My System Specs![]() |
| | #9 (permalink) |
| | Re: a stupid question on word.application Il 13/03/2009 21.17, T Lavedas ha scritto: Quote: > > See WSH 5.6 documentation download (URL all one line) > http://www.microsoft.com/downloads/d...displaylang=en > > Tom Lavedas Thanks It works, but in files as "firstFile.OfThisYear.txt" this function is not precise. ok, but at which point I have to delete the fso object? In the function first of end function? bye Gianluca |
My System Specs![]() |
| | #10 (permalink) |
| | Re: a stupid question on word.application On Mar 13, 4:05*pm, gianbrix <---***gilucasa***...@xxxxxx> wrote: Quote: > Il 13/03/2009 21.17, T Lavedas ha scritto: > > > Quote: > > See WSH 5.6 documentation download (URL all one line) > >http://www.microsoft.com/downloads/d...d=01592C48-207.... Quote: > > Tom Lavedas > Thanks > It works, but in files as > "firstFile.OfThisYear.txt" this function is not precise. > ok, but at which point I have to delete the fso object? > In the function first of end function? > bye > Gianluca but unless you're short of memory, I don't see the need. Plus, if they are defined local to a function or subroutine, they're released when the routine exits. If the WITH construct is used, they are released at the END WITH statement. Otherwise, they are released when the script execution ends. Tom Lavedas ========== |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: stupid question | VB Script | |||
| Stupid question? | Vista General | |||
| This may be a stupid question, but here goes... | Vista General | |||
| Stupid question | Vista mail | |||
| this is probably a very stupid question | Vista General | |||