LuaCOM Word Document opening

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

LuaCOM Word Document opening

aryajur
Hi,
       I am using LuaCOM to open a word document but I get this error:

> word.Documents.Open("D:/1.docx")
COM error:(.\src\library\tLuaCOM.cpp,403):Type mismatch.
stack traceback:
        [C]: in function 'Open'
        stdin:1: in main chunk
        [C]: ?


The function works fine if I use it from VBA. Can anyone help me figuring out why this does not work?

Thanks,
Milind

Reply | Threaded
Open this post in threaded view
|

Re: LuaCOM Word Document opening

Jonathan Goble
On Sat, Aug 8, 2015 at 12:50 AM, Milind Gupta <[hidden email]> wrote:
>> word.Documents.Open("D:/1.docx")

I'm not familiar with LuaCOM, but Windows paths use backslashes, so
unless LuaCOM is converting it automatically, you want "D:\\1.docx"
(doubled because you have to escape a literal backslash to prevent it
from being treated as special). Could that be causing the problem?

Reply | Threaded
Open this post in threaded view
|

Re: LuaCOM Word Document opening

Robert Raschke
In reply to this post by aryajur

Is it possible that the Word Open() COM function takes more than one parameter? If I remember correctly in LuaCOM you'd need to provide all of them, there not being a way to have default params.

Hth,
Robby

On Aug 8, 2015 6:50 AM, "Milind Gupta" <[hidden email]> wrote:
Hi,
       I am using LuaCOM to open a word document but I get this error:

> word.Documents.Open("D:/1.docx")
COM error:(.\src\library\tLuaCOM.cpp,403):Type mismatch.
stack traceback:
        [C]: in function 'Open'
        stdin:1: in main chunk
        [C]: ?


The function works fine if I use it from VBA. Can anyone help me figuring out why this does not work?

Thanks,
Milind

Reply | Threaded
Open this post in threaded view
|

Re: LuaCOM Word Document opening

Rena
In reply to this post by Jonathan Goble


On Aug 8, 2015 1:42 AM, "Jonathan Goble" <[hidden email]> wrote:
>
> On Sat, Aug 8, 2015 at 12:50 AM, Milind Gupta <[hidden email]> wrote:
> >> word.Documents.Open("D:/1.docx")
>
> I'm not familiar with LuaCOM, but Windows paths use backslashes, so
> unless LuaCOM is converting it automatically, you want "D:\\1.docx"
> (doubled because you have to escape a literal backslash to prevent it
> from being treated as special). Could that be causing the problem?
>

Windows will accept forward slashes as well, unless something funny is going on.

Reply | Threaded
Open this post in threaded view
|

Re: LuaCOM Word Document opening

aryajur

Thanks for the replies. I tried forward slash and double back slash as well. Finally this worked:

word.Document:Open("D:/1.docx")   -- notice the colon between Document and Open

On Aug 8, 2015 5:14 AM, "Rena" <[hidden email]> wrote:


On Aug 8, 2015 1:42 AM, "Jonathan Goble" <[hidden email]> wrote:
>
> On Sat, Aug 8, 2015 at 12:50 AM, Milind Gupta <[hidden email]> wrote:
> >> word.Documents.Open("D:/1.docx")
>
> I'm not familiar with LuaCOM, but Windows paths use backslashes, so
> unless LuaCOM is converting it automatically, you want "D:\\1.docx"
> (doubled because you have to escape a literal backslash to prevent it
> from being treated as special). Could that be causing the problem?
>

Windows will accept forward slashes as well, unless something funny is going on.