Problems with SaveAs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mark13.pl@gmail.com

    Problems with SaveAs

    Hi,

    In word macro such thing worked perfectly:
    With ActiveDocument
    .SaveEncoding = msoEncodingUTF8
    .SaveAs FileName:="c:\t est.doc",
    FileFormat:=wdF ormatUnicodeTex t
    End With

    When I tried to use it in pure VB.net I put:

    oWord = CreateObject("W ord.Application ")
    With oWord.ActiveDoc ument
    .SaveEncoding = msoEncodingUTF8
    .SaveAs FileName:="c:\t est.doc",
    FileFormat:=wdF ormatUnicodeTex t
    End With

    but all the time got an error in 'saveEncoding' line. I tried with
    msoEncodingUTF8 , with string "msoEncodingUTF 8" and with
    oWord.msoEncodi ngUTF8 but all the time got some errors (like {"Type
    mismatch (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMIS MATCH))"}
    How can I make it works??

    Thank you, mark

  • Pritcham

    #2
    Re: Problems with SaveAs

    Hi Mark

    I would say that the reason you're having problems is because in Word
    you're setting the fileformat property to an Enum defined by word (and
    therefore not recognised by VB). What you'd need to do is to establish
    what the Enum equates to and use that in your VB code instead of the
    Enum name.

    Hope that helps
    Martin
    mark13.pl@gmail .com wrote:
    Hi,
    >
    In word macro such thing worked perfectly:
    With ActiveDocument
    .SaveEncoding = msoEncodingUTF8
    .SaveAs FileName:="c:\t est.doc",
    FileFormat:=wdF ormatUnicodeTex t
    End With
    >
    When I tried to use it in pure VB.net I put:
    >
    oWord = CreateObject("W ord.Application ")
    With oWord.ActiveDoc ument
    .SaveEncoding = msoEncodingUTF8
    .SaveAs FileName:="c:\t est.doc",
    FileFormat:=wdF ormatUnicodeTex t
    End With
    >
    but all the time got an error in 'saveEncoding' line. I tried with
    msoEncodingUTF8 , with string "msoEncodingUTF 8" and with
    oWord.msoEncodi ngUTF8 but all the time got some errors (like {"Type
    mismatch (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMIS MATCH))"}
    How can I make it works??
    >
    Thank you, mark

    Comment

    • mark13.pl@gmail.com

      #3
      Re: Problems with SaveAs

      Hello,
      I would say that the reason you're having problems is because in Word
      you're setting the fileformat property to an Enum defined by word (and
      therefore not recognised by VB).
      Thank you for your answer :). Yes, that was the problem. Finally I
      solved it.
      If someone is interested in getting these values please feel free to
      contact me priv.

      Regards, mark

      Comment

      Working...