Hello,
I have to write a lot of functional designs for my company and they all use chapters that are the same every time. Sometimes i need a certain chapter the next time i dont need that chapter but several other ones.
I now have all seperate chapters saved in seperated word document, like : chapter_a.docx chapter_b.docx ....
I also created a visual basic code that is able to add the content of an external word document to the current document.
The thing i'm looking for know is that I can show a dialog to the user from where he can select one more more chapters which are then copied in the document.
[] chapter_a
[x] chapter_b
[] chapter_c
[x] chapter_d
[] chapter_e
and so one.
Two questions ;
1. How do I create such a dialog and pass the selected values to a subroutine
2. What is the best way to startup this code ie. when creating / opening the document the first time or can i assign a special key combination to start this dialog.
-----
The code that i have now is created using the function to record a Macro but it works so far.
Code:
Sub FilesToCopy()
Call CopyPasteFromExternalFile("c:\isp\Hoofdstuk1.docx")
Call CopyPasteFromExternalFile("c:\isp\Hoofdstuk2.docx")
End Sub
Sub CopyPasteFromExternalFile(strFileToPaste As String)
'
' CopyPasteFromExternalFile Macro
' Test om content van externe bestanden te kopieren
'
Documents.Open FileName:=strFileToPaste, ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.WholeStory
Selection.Copy
ActiveWindow.Close
Selection.EndKey Unit:=wdStory
Selection.PasteAndFormat (wdFormatOriginalFormatting)
End Sub
------
Hope somebody can help me out.
Erik