Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 04-12-2018, 07:44 AM
RMerckling RMerckling is offline Copy & Paste Word Doc from Excel VBA Windows 7 64bit Copy & Paste Word Doc from Excel VBA Office 2010 32bit
Novice
Copy & Paste Word Doc from Excel VBA
 
Join Date: Jan 2018
Posts: 29
RMerckling is on a distinguished road
Default Copy & Paste Word Doc from Excel VBA

Hi all,

Attempting to simplify an existing process. Right now I have users copying & pasting an Excel Workbook and a Word Document ("Plan Doc") into specific folders, filling out the Excel Workbook then running a Mail Merge through the Plan Doc.

New Process:
I'd like the user to copy & paste the Excel Workbook into their desired folder and after filling out the Excel Workbook's cells to be utilized by Mail Merge, run a VBA code that copies the Plan Doc (will always have the same location) into the same folder as the newly placed Excel Workbook and re-names it based on certain cell values in Excel.



Attaching an example Excel Workbook with some examples of what the user would be filling out. These fields in Excel Workbook are used in the Plan Doc as a Mail Merge. Eventually, I'd like to automate the Excel VBA to contain code to run a Mail Merge in the Plan Doc after copying / pasting the Plan Doc... but one step at a time.

Forgive me if this is confusing, I'd be happy to answer any questions.

Thanks,
Rich
Attached Files
File Type: xlsx TestWorkbook.xlsx (8.5 KB, 11 views)
  #2  
Old 04-14-2018, 08:14 PM
BobBridges's Avatar
BobBridges BobBridges is offline Copy & Paste Word Doc from Excel VBA Windows 7 64bit Copy & Paste Word Doc from Excel VBA Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

I don't know from Mail Merge—I've done it a few times, but not often enough to remember how—but it seems all you want, at least for now, is to copy a document with a known path and name to a new document with the current path and a calculated name. Nothing hard or complex about that, right? What am I missing?

First you calculate the new Word document name, probably using this formula:
Code:
=$C$2&" "&$C$4&" "&$C$3&" "&$C$6&" "&TEXT($C$7,"m-d-yyyy")&"-"&TEXT($C$8,"m-d-yyyy")&".docx"
Then you have code that fetches a copy of the template (so to speak) from the old location, and copy it to C:\<current path>\<calculated filename>.

Either I've misunderstood you, or there's some part of that you don't know how to do. If the latter, which part? I don't want to insult you by telling you all the things you already know and leaving out the one part that's confusing you.

For the copying part, you could open up the Word application, then do an Open and a Save-As. But I'm sure it'll be simpler to access some Windows feature that does file copies. Is that the part you're having trouble with? Because if it is, I'd have to google it myself. Won't be hard, though.
  #3  
Old 04-14-2018, 10:21 PM
macropod's Avatar
macropod macropod is offline Copy &amp; Paste Word Doc from Excel VBA Windows 7 64bit Copy &amp; Paste Word Doc from Excel VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

This seems to be a resurrection of your discussion in: https://www.msofficeforums.com/word-...le-create.html for which you have yet to provide the documentation requested. Kindly keep discussions on a particular topic in a single thread.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #4  
Old 04-18-2018, 09:54 AM
RMerckling RMerckling is offline Copy &amp; Paste Word Doc from Excel VBA Windows 7 64bit Copy &amp; Paste Word Doc from Excel VBA Office 2010 32bit
Novice
Copy &amp; Paste Word Doc from Excel VBA
 
Join Date: Jan 2018
Posts: 29
RMerckling is on a distinguished road
Default

Code:
Sub CopyandRename()
    Dim str1 As String
    Dim str2 As String
    str1 = "Q:\IC\New Structure\IC Toolkit\Templates\01 Plan Doc Template\16 Source\IC Plan Doc Template v1.0.docx"
    str2 = Application.ActiveWorkbook.Path & "\" & Range("A1").Value & ".docx"
    
    Call FileCopy(str1, str2)
    
'Opens New Plan Doc Template
    Set appWd = CreateObject("Word.Application")
    appWd.Visible = True

    appWd.Documents.Open Filename:=Application.ActiveWorkbook.Path & "\" & Worksheets("Form").Range("A1").Value & ".docx"

End Sub
  #5  
Old 04-18-2018, 03:57 PM
macropod's Avatar
macropod macropod is offline Copy &amp; Paste Word Doc from Excel VBA Windows 7 64bit Copy &amp; Paste Word Doc from Excel VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

You don't seem to be paying attention. Thread closed. Kindly keep all of the discussion in your original thread.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Closed Thread

Tags
excel 2010, excel vba, word 2010



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy &amp; Paste Word Doc from Excel VBA Copy/paste from Excel to Word problems! mross127 Word 10 08-16-2017 04:41 PM
Copy Underline text from Word and Paste into excel rfaris Excel Programming 7 10-05-2015 05:56 AM
Copy &amp; Paste Word Doc from Excel VBA Copy/Paste EXCEL cells as pic in WORD A_Lau Drawing and Graphics 3 12-19-2014 06:57 AM
Copy &amp; Paste Word Doc from Excel VBA Word 2007 Copy/Paste Excel issue raven26c Word 1 11-18-2011 02:49 AM
copy/paste charts from excel to word bielak01 Excel 0 04-16-2009 02:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:26 AM.


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