Sign in to follow this  
Followers 0
obscurant1st

Help on combining two word files

9 posts in this topic

Hi,

I have two word files which i have to combine one after the other, it is containing lots of formatting and all. Sohow can i use auto it for combining both.

Is there any UDFs for this?

also I need to include Page Breaks after some predefined words.

Share this post


Link to post
Share on other sites



Hi,

I have two word files

What you mean - two MS Word documents?

Best Regards BugFix  

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

OK, this works so:

#include <Word.au3>
$sPath1 = "file1.doc"
$sPath2 = "file2.doc"
$oWord = _WordCreate($sPath1, 0, 1) ; visible
With $oWord.Selection
    .EndKey(6)
    .InsertBreak(7)
    .InsertFile($sPath2)
EndWith

Edit:

Best way to find out this: Make an macro in word, that this things do, than open VBA and translate this to autoit-code.

Edited by BugFix

Best Regards BugFix  

Share this post


Link to post
Share on other sites

will this work with .docx format also? :idea:

coz i am getting an error like

: ==> The requested action with this object has failed.:
$o_doc = $o_object.Documents.Open ($s_FilePath, $f_ConfirmConversions, $f_ReadOnly, $f_AddToRecentFiles, $s_PasswordDocument, "", $f_Revert, $s_WritePasswordDocument, "", $i_Format)
$o_doc = $o_object.Documents.Open ($s_FilePath, $f_ConfirmConversions, $f_ReadOnly, $f_AddToRecentFiles, $s_PasswordDocument, "", $f_Revert, $s_WritePasswordDocument, "", $i_Format)^ ERROR

Share this post


Link to post
Share on other sites

Add this toward the top of your script.

_WordErrorHandlerRegister()

Share this post


Link to post
Share on other sites

>Running:(3.3.6.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\oDx\Desktop\Macro\test.au3"    
C:\Program Files\AutoIt3\Include\Word.au3 (1293) : ==> Variable used without being declared.:
Return SetError($_WordStatus_Success, 0, 1)
Return SetError(^ ERROR

then this error comes!! :idea:

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

sorry for the double post, but i really need some help here, pls!! :|

Edit: solved

I had to give "_WordErrorHandlerRegister()" after header file, i wax giving it the begining!

thanks!!! :idea:

Edited by obscurant1st

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0