Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-11-2012, 11:55 AM
MrRikkie MrRikkie is offline Dynamically create documents Windows 7 32bit Dynamically create documents Office 2010 32bit
Novice
Dynamically create documents
 
Join Date: Oct 2012
Posts: 1
MrRikkie is on a distinguished road
Default Dynamically create documents

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
Reply With Quote
  #2  
Old 10-12-2012, 09:15 AM
macropod's Avatar
macropod macropod is offline Dynamically create documents Windows 7 64bit Dynamically create documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

What you'll need for this is a userform with checkboxes for the various chapters and code to test whether a particular checkbox is checked and, if so, import the corresponding chapter.

To see how to create & use a userform, see:
http://gregmaxey.com/word_tip_pages/..._userForm.html
http://www.fontstuff.com/vba/vbatut09a.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically create documents Have Powerpoint dynamically update from an excel or other file? oshkosh PowerPoint 3 04-05-2016 06:10 AM
Dynamically create documents Linking Documents via Hyperlinks to create a "packet" moose288 Word 3 09-22-2012 08:22 PM
draw charts dynamically pouya7525 PowerPoint 0 09-06-2012 10:45 AM
Dynamically create documents Dynamically creating new drop down boxes. dmncs Word VBA 1 05-06-2012 09:29 PM
Dynamically create documents How do I dynamically update data in a Word Document from a database table RSchmidt Word 1 07-14-2011 04:27 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft