2010-07-12 3 views
2

Qt 4.5를 사용하고 ActiveQt를 사용하여 MS Word 문서를 생성하고 있습니다. MS Word 용 VBA의 ActiveX 명령을 기반으로 문서를 만들 수 있습니다. 그러나 원하는 위치에 새 페이지를 만들 수는 없습니다. Qt를 사용하여 MS Word에서 새 페이지 추가

나는
selection->dynamicCall("InsertBreak(const QString &)","wdPageBreak"); 
selection->dynamicCall("InsertParagraph(void)"); 
QAxObject *partTableParagraph = activeDocument->querySubObject("Paragraphs(1)"); 
partTableParagraph->setProperty("PageBreakBefore","True"); 
QAxObject *partTableRange = partTableParagraph->querySubObject("Range"); 
selection->dynamicCall("TypeText(const QString&)","second page contents"); 

을 시도하지만 여전히 나는 워드 문서에 새 페이지를 만들 수 없습니다입니다. 또한 내용은 두 번째 페이지에 표시되지 않습니다. 즉 second page contents은 보이지 않습니다.

이에 대한 모든 안내는 환영합니다.

답변

0

먼저 VBA 매크로로 작성하는 것이 좋습니다. 일단 VBA에서 작업하게되면 ActiveQt로 바로 변환 할 수 있습니다.

0

이 코드를 사용해보십시오.

write("This is a test. "); 
write("With no newline but with a page break"); 
writePageBreak(); 
write("But this has a newline at the beginning and the end\n"); 

당신은 This is a test. With no newline but with a page break로 끝나는 것입니다 : 예를 들어

void insertNewPage() { 
    QAxObject* activeWindow = activeDocument->querySubObject("ActiveWindow"); 
    QAxObject* selection = activeWindow->querySubObject("Selection"); 
    selection->dynamicCall("Collapse(int)", 0); 
    selection->dynamicCall("InsertNewPage()"); 
    selection->dynamicCall("Collapse(int)", 0); 
} 

당신이 당신의 문서를 작성하는 write 방법이 여겨 : 나는이 메소드를 호출 할 때마다 새 페이지를 삽입 할 수있어 한 페이지에서는 But this has a newline at the beginning and the end이고 다른 페이지에서는 But this has a newline at the beginning and the end입니다. 지금까지

QAxObject* selection = activeWindow->querySubObject("Selection"); 
selection->dynamicCall("InsertAfter(const QString&)",text); 

과 :

나는 :) 두 번째 페이지가 비어있는 이유에 관해서는

하지만 ... 내가 말씀에 기록이 사용 NULL 포인터를 확인하고 있지 않다 그것은 효과가있다.

관련 문제