2009-08-27 3 views
3

rst 소스를 저장할 수 있도록 reStructuredText을 MS Word 문서 도구 체인에 구축하려고합니다. 버전 제어.OpenOffice.org 기본 매크로를 사용하여 * .odt 파일을 MS Word * .doc 파일로 프로그래밍 방식으로 변환하십시오.

지금까지 I -

는 OpenOffice.org Writer를 형식으로 reStructuredText을 변환하는 rst2odt.py 되세요.

다음으로 내가 가장 최근의 OpenOffice.org를 사용하려면 (현재 3.1)를 Word 97에서/2000/XP 문서를 생성하는 꽤 괜찮은 일을, 그래서 매크로 쓴 :

sub ConvertToWord(file as string) 
    rem ---------------------------------------------------------------------- 
    rem define variables 
    dim document as object 
    dim dispatcher as object 
    rem ---------------------------------------------------------------------- 
    rem get access to the document 
    document = ThisComponent.CurrentController.Frame 
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 

    rem ---------------------------------------------------------------------- 
    dim odf(1) as new com.sun.star.beans.PropertyValue 
    odf(0).Name = "URL" 
    odf(0).Value = "file://" + file + ".odt" 
    odf(1).Name = "FilterName" 
    odf(1).Value = "MS Word 97" 
    dispatcher.executeDispatch(document, ".uno:Open", "", 0, odf()) 

    rem ---------------------------------------------------------------------- 
    dim doc(1) as new com.sun.star.beans.PropertyValue 
    doc(0).Name = "URL" 
    doc(0).Value = "file://" + file + ".doc" 
    doc(1).Name = "FilterName" 
    doc(1).Value = "MS Word 97" 

    dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, doc()) 
end sub 

을하지만, 내가 그것을 실행하면 :

soffice "macro:///Standard.Module1.ConvertToWord(/path/to/odt_file_wo_ext)" 

내가받을 : "기본 런타임 오류. 속성 또는 메서드를 찾을 수 없습니다." 줄에 메시지 :

document = ThisComponent.CurrentController.Frame 

그리고 때 그 라인이 에러없이 완료 위의 호출을 언급하지만, 아무것도하지 않습니다. 나는 새로 만든 인스턴스에 document의 값을 어떻게 든 설정해야한다고 생각하지만, 어떻게해야할지 모르겠다.

아니면 완전히 뒤로 향하고 있습니까?

P. 내 의존성을 최소화하려고하기 때문에 나는 대체로 JODConverter을 고려할 것이다.

답변

0

OpenOffice/LibreOffice에서 DOC 필터를 개선 할 때마다 매번 매크로를 설치/업그레이드/테스트 할 필요가 없기 때문에 JODConverter (대체 제품)를 사용하는 것이 좋습니다. 그것은 꽤 잘 입증되었습니다.

관련 문제