Jump to content
Sign in to follow this  

Recommended Posts

Hi

I am working on a requirement to merge multiple word documents with data(text/pictures) copied from PPT slides and pasted into a document [Ex-Sol_S006.docx].

When I am trying to combine / merge same 3 documents in different order, it is failing for order [5,6,4], (By Failing, I mean - It is Asking a prompt to Save and on click of Save it is not saving and forcing me to cancel to terminate/continue with the program run), 

Orders [6,4,5] and [4,5,6] - I am getting a merged document saving thru program, without any "Save" prompt.

Unable to find out any reason for such a behaviour. Please Help!

OpenWord()

   For $intJ = 1 to 3
          $oDoc = _Word_DocOpen($oWordApp, $strTemplatePath)
          $oDoc.Documents.Add
          For $intI = 1 to 3
                $rng = $oDoc.Bookmarks("\EndOfDoc").Range
                 If $rng.End > 0 Then ;;'section break not necessary before first document.'
                     ;$rng.InsertBreak wdSectionBreakNextPage
                      $rng.InsertBreak Type:=7            ;;wdSectionBreakNextPage-2 ; PageBreak - 7
                     $rng.Collapse (0)        ;;wdCollapseEnd - 0
                  EndIf
                  If $intJ = 1 Then
                     If $intI = 1 Then
                        $strExtFileName = "Sol_S006.docx"
                     ElseIf $intI = 2 Then
                        $strExtFileName = "Sol_S004.docx"
                     ElseIf $intI = 3 Then
                        $strExtFileName = "Sol_S005.docx"
                     EndIf
                  ElseIf $intJ = 2 Then
                     If $intI = 1 Then
                        $strExtFileName = "Sol_S004.docx"
                     ElseIf $intI = 2 Then
                        $strExtFileName = "Sol_S005.docx"
                     ElseIf $intI = 3 Then
                        $strExtFileName = "Sol_S006.docx"
                     EndIf
                  ElseIf $intJ = 3 Then
                     If $intI = 1 Then
                        $strExtFileName = "Sol_S005.docx"
                     ElseIf $intI = 2 Then
                        $strExtFileName = "Sol_S006.docx"
                     ElseIf $intI = 3 Then
                        $strExtFileName = "Sol_S004.docx"
                     EndIf
                  EndIf
                  If $strExtFileName <> "" Then
                     $rng.InsertFile ($strSourcePath & $strExtFileName)
                  EndIf
                  $strExtFileName = ""
               Next
               Local $strSavePath = $strMergedDocPath & "Mergedoc" & $intJ & ".docx"
           _Word_DocSaveAs($oDoc, $strSavePath, 12)
           _Word_DocClose($oDoc)
   Next

   _Word_Quit($oWordApp)

Share this post


Link to post
Share on other sites

One of my colleague has sharead a link giving some info on "Endless Save" prompt.

One of the post has suggested to FIRST Save it as RTF, Close the Files and then re-Save it as DOCX.

This has worked out for me :-) 

THANK YOU. 

              Local $strSavePathRTF = $strMergedDocPath & "Mergedoc" & $intJ & ".rtf"
                Local $strSavePathDocx = $strMergedDocPath & "Mergedoc" & $intJ & ".docx"
           _Word_DocSaveAs($oDoc, $strSavePathRTF, 6)
           _Word_DocClose($oDoc)
           $oDoc = _Word_DocOpen($oWordApp, $strSavePathRTF)
           _Word_DocSaveAs($oDoc, $strSavePathDocx, 16)
           _Word_DocClose($oDoc)

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Kiko745
      Hello!
      I am new to autoit so please if someone could help me. I am trying to combine multiple .txt files but I can't get it right. In every file are the exact amout of lines ( for example here are 2 ) ,            I don't want to make it for just 2 lines for each txt files but for all the lines the txt files contains. The thing I want to do is :
      Text File 1
      Hello my name
      I am a big
      ...
      Text File 2
      is Fred,
      Potato head for
      ...
      Text File 3
      and I like to eat pizza.
      Not getting this right.
      ...
      ------------------- Combine them all into one txt file like here ------------------------------
      Final Text file
      Hello my name is Fred, and I like to eat pizza.
      I am a big Potato head for Not getting this right.
      ...
       
      Thanks for any advice!
      P.S. Sorry for my English, not my first language.
       
×
×
  • Create New...