FlexPro
HistoryBase
Ingénierie
Formation
Téléchargements
Support FlexPro
Connaissance
Communauté
À propos de nous
Références
Emplois
Contact général
Liste des revendeurs
Support FlexPro
FR
DE
EN
Porte-plaquette
Produits et solutions
Support et téléchargements
Entreprise
Magazine
Contact
Langue
MyWeisang

Paramètres du compte.

Topic

Append many documents in a new one

Page d'accueil ' Communauté ' Automation et VBA ' Appliquer de nombreux documents en un seul

Voir les messages de 5 - 1 à 5 (sur un total de 5)
  • Auteur
    Messages
  • #34962
    Nicolas Beaupré
    Participant

    Hi,
    Is there a way in VBA to append documents? (or pages) In Flexpro, I can open an empty document and, with drag and drop, I insert another existing document in the new one. It is added at the end of the open document. How may I do that in VBA?

    For example, in my application, I got a lot of small “report_x” document. I want to create a new document named “GlobalReport” wich is the sum of all the others document. After doing this, I’ll be able to edit the pages number of “GlobalReport” and print it alone.

    Thanks!

    #34966
    Nicolas Beaupré
    Participant

    Hi,
    Is there a way in VBA to append documents? (or pages) In Flexpro, I can open an empty document and, with drag and drop, I insert another existing document in the new one. It is added at the end of the open document. How may I do that in VBA?

    For example, in my application, I got a lot of small “report_x” document. I want to create a new document named “GlobalReport” wich is the sum of all the others document. After doing this, I’ll be able to edit the pages number of “GlobalReport” and print it alone.

    Thanks!

    #34963
    Bernhard Kantz
    Participant

    In FlexPro there is no method to append a document to another document.

    But there is the possibility to select the shapes of the document. Then you can use the [b]Copy[/b] and the [b]Paste[/b] method.

    Example:
    [code]
    Dim oSourceDoc As Document
    Dim oDestDoc As Document
    Dim i As Integer

    Set oSourceDoc = ActiveDatabase.RootFolder.Object(“Doc1”, fpObjectTypeDocument)
    Set oDestDoc = ActiveDatabase.RootFolder.Object(“Doc2”, fpObjectTypeDocument)

    Dim oPage As Shapes
    Set oPage = oSourceDoc.Pages(1)
    For i = 1 To oPage.Count
    oSourceDoc.Select
    oSourceDoc.Selection.Collapse
    oPage.Item(i).Select
    oSourceDoc.Selection.Copy
    oDestDoc.Select
    oDestDoc.Selection.Paste
    oDestDoc.Selection.Collapse
    Next i
    [/code]

    support@weisang.com

    #34964
    Nicolas Beaupré
    Participant

    Thanks for the code! It works, but I had to add these lines :[code] oSourceDoc.Select
    [b]oSourceDoc.Open = True[/b]
    oSourceDoc.Selection.Collapse
    oPage.Item(i).Select
    oSourceDoc.Selection.Copy
    oDestDoc.Select
    [b]oDestDoc.Open = True[/b]
    oDestDoc.Selection.Paste
    oDestDoc.Selection.Collapse[/code]
    Otherwise, the operations .Collapse and .Paste couldn’t work when the documents are closed.

    Also, this code copies the shapes in the first page of my document. Suppose I add a new page in the document [code]Dim oNewPage As Shapes
    Set oNewPage = oSourceDoc.pages.Add[/code] How can I select the new page so the shape will be copied in it ?

    Thanks

    #34965
    Bernhard Kantz
    Participant

    You can use the methods [b]NextPage[/b] and [b]PreviousPage[/b] of a DocObjectSelection object.

    [code]
    oDestDoc.Selection.PreviousPage
    oDestDoc.Selection.NextPage
    [/code]

    support@weisang.com

Voir les messages de 5 - 1 à 5 (sur un total de 5)
  • Vous devez être connecté pour répondre à ce sujet.