473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Copy files (old kind) from folders in sequence and paste into one word document

Hi Guys

I found an old thread discussing almost something similar
http://bytes.com/topic/visual-basic-...xt-file-folder

but im look for a way to open files in sequence in a folder and copy paste them into my word document.

the related one i found opens the next file but i want to copy and paste them in my active document.

Expand|Select|Wrap|Line Numbers
  1. Sub B07LoadingCond()
  2. '
  3.  
  4.     Dim LC1 As Document
  5.     Dim LC2 As Document
  6.     Dim LC3 As Document
  7.     Dim LC4 As Document
  8.     Dim LC5 As Document
  9.     Dim LC6 As Document
  10.     Dim LC7 As Document
  11.     Dim LC8 As Document
  12.     Dim LC9 As Document
  13.     Dim LC10 As Document
  14.     Dim Chapter7 As Document
  15.     Dim newdoc As Document
  16.  
  17.     Dim Path As String
  18.     Dim Path1 As String
  19.     Dim Path2 As String
  20.     Dim Path3 As String
  21.     Dim Path4 As String
  22.     Dim Path5 As String
  23.     Dim Path6 As String
  24.     Dim Path7 As String
  25.     Dim Path8 As String
  26.     Dim Path9 As String
  27.     Dim Path10 As String
  28.     Dim Path11 As String
  29.  
  30.     Dim rng As Range
  31.  
  32.     Path = "y:\Chapter 7 - LCs"
  33.     Path1 = Path & "\LC1.rtf"
  34.     Path2 = Path & "\LC2.rtf"
  35.     Path3 = Path & "\LC3.rtf"
  36.     Path4 = Path & "\LC4.rtf"
  37.     Path5 = Path & "\LC5.rtf"
  38.     Path6 = Path & "\LC6.rtf"
  39.     Path7 = Path & "\LC7.rtf"
  40.     Path8 = Path & "\LC8.rtf"
  41.     Path9 = Path & "\LC9.rtf"
  42.     Path10 = Path & "\LC10.rtf"
  43.     Path11 = Path & "\Chapter7.docx"
  44.  
  45.     Set newdoc = Documents.Add
  46.     newdoc.SaveAs Path11
  47.  
  48.     Set LC1 = Documents.Open(Path1)
  49.     Set LC2 = Documents.Open(Path2)
  50.     Set LC3 = Documents.Open(Path3)
  51.     Set LC4 = Documents.Open(Path4)
  52.     Set LC5 = Documents.Open(Path5)
  53.     Set LC6 = Documents.Open(Path6)
  54.     Set LC7 = Documents.Open(Path7)
  55.     Set LC8 = Documents.Open(Path8)
  56.     Set LC9 = Documents.Open(Path9)
  57.     Set LC10 = Documents.Open(Path10)
  58.  
  59.     Set Chapter7 = Documents.Open(Path11)
  60.  
  61.     LC1.Content.Copy
  62.     Set rng = Chapter7.Content
  63.     rng.Collapse Direction:=wdCollapseEnd
  64.     rng.Paste
  65.  
  66.  
  67.     LC2.Content.Copy
  68.     Set rng = Chapter7.Content
  69.     rng.Collapse Direction:=wdCollapseEnd
  70.     rng.Paste
  71.  
  72.  
  73.     LC3.Content.Copy
  74.     Set rng = Chapter7.Content
  75.     rng.Collapse Direction:=wdCollapseEnd
  76.     rng.Paste
  77.  
  78.  
  79.     LC4.Content.Copy
  80.     Set rng = Chapter7.Content
  81.     rng.Collapse Direction:=wdCollapseEnd
  82.     rng.Paste
  83.  
  84.  
  85.     LC5.Content.Copy
  86.     Set rng = Chapter7.Content
  87.     rng.Collapse Direction:=wdCollapseEnd
  88.     rng.Paste
  89.  
  90.  
  91.     LC6.Content.Copy
  92.     Set rng = Chapter7.Content
  93.     rng.Collapse Direction:=wdCollapseEnd
  94.     rng.Paste
  95.  
  96.  
  97.     LC7.Content.Copy
  98.     Set rng = Chapter7.Content
  99.     rng.Collapse Direction:=wdCollapseEnd
  100.     rng.Paste
  101.  
  102.     LC8.Content.Copy
  103.     Set rng = Chapter7.Content
  104.     rng.Collapse Direction:=wdCollapseEnd
  105.     rng.Paste
  106.  
  107.     LC9.Content.Copy
  108.     Set rng = Chapter7.Content
  109.     rng.Collapse Direction:=wdCollapseEnd
  110.     rng.Paste
  111.  
  112.     LC10.Content.Copy
  113.     Set rng = Chapter7.Content
  114.     rng.Collapse Direction:=wdCollapseEnd
  115.     rng.Paste
  116.  
  117.     LC1.Close SaveChanges:=False
  118.     LC2.Close SaveChanges:=False
  119.     LC3.Close SaveChanges:=False
  120.     LC4.Close SaveChanges:=False
  121.     LC5.Close SaveChanges:=False
  122.     LC6.Close SaveChanges:=False
  123.     LC7.Close SaveChanges:=False
  124.     LC8.Close SaveChanges:=False
  125.     LC9.Close SaveChanges:=False
  126.     LC10.Close SaveChanges:=False
  127.     Chapter7.SaveAs Path11
  128.  
  129.  
  130. End Sub

of course you can see there is another problem im pointing to a specific file name. That I dont want and only want to use a fill in form where the user selects the root folder and click run.

any help on some of the above please?
Dec 25 '14 #1
1 1192
subject line shouldve read
Copy files (all kind) from folders in sequence and paste into one word document

all kind meaning some rtf files some jpg files etc

there are 12 folders (or more)
with 10files in each folder (or less/more)

tnx guys
Dec 25 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: MLH | last post by:
I have tblFiles with and fields. DLookUp("","tblFiles","=22") returns "c:\EMLfiles\00002.eml". The return string is a pointer to a dot-eml file in c:\EMLfiles. The dot-eml file was created in...
3
by: Bob | last post by:
What I want to do is write a program that reads through a Word Document, finds certain words or sentences I want, and then paste into an Excel spreadsheet. I dont know much about C#. But I...
2
by: KnotKnormal | last post by:
I would like to dynamically load a HTML page (or a Word document), which is embedded in a table when the user clicks on a hyperlink to go from HTML page one to HTML page two. For example, I would...
3
by: Adam Faulkner via DotNetMonster.com | last post by:
I want to create a method within a class that opens a Microsoft Word 2000 Document and has the facility to Create a new word document and then extract a Page that exists within the original Word...
1
by: Adam Faulkner via DotNetMonster.com | last post by:
I had a problem before extracting pages from an existing word document and then inserting the content into a new word document. The following code below works with Microsoft Word 2000 Function...
0
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
0
by: PracticalApps | last post by:
I looked to find a canned solution to create a Word document in my application and just couldn't find anything that just gets to the point. I would think, and I may be making too strong of an...
5
by: deve8ore | last post by:
Hello, I have a Word document called (), a named range that will open up a new Word doc dependent on what a user selects in Excel. Could someone please guide me on how to set up VBA code to...
0
by: TOPSie | last post by:
I used http://support.microsoft.com/kb/316383/en-us as the basis of some code to generate a Word document using VB code (.NET2005). In the code I have a loop which produces a table and in the...
6
by: Paul Mc | last post by:
Hi all, It's a little late in the day for me so please forgive as i need my bed.!! The issue is i need to open a word doc (say "c:\temp.doc) and paste into it, but i only can work out how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.