Excel: Add to Macro - Move additional Text from Excel to Word doc


Hello - Thank you for looking. I have a Working Macro that has saved me countless time with increased data accuracy across the last years that was created with Help of others more knowledgable than I. I am using - Windows XP SP3 & Office XP and 2003. I would like to add a feature to this Macro that will add info to the end product making it more useable and again saving time. My Macro cuts one designated row from One Workbook and Places it in Another at the next available row position. It then copies a specified cell and places the text in a Named Open Word Document at the position of the cursor. I would like to Copy text from three additional Cells of that same last row and place them in another spot in the Open Word Document. The additional text would all be placed on one line with space dash space between them/ The last row is currently left highlighted. Im envisioning that leaving the current macro as is and adding code to the end to return to the highlighted row to copy the cells I need and then pasting them into the word document. I'm puzzled as to how to specify the location that I want the Additional text copied to. My thoughts say that the current code could be modified to leave the cursor at the desired position ( its not the position of the previous paste ) - but unsure how to do that. OR, designating the position for the paste to be the first row after any row containing 6 or more dashes. ( -------- ) The Text would be in Cells S , AQ and AO of the last ( just transfered ) row of the Excel Workbook Named AMZ-GM Sold.xls. Here is my Current Code.


Sub OpenToSold()
' OpentoSold Macro Moves Sold Items from Amz Open to Sold and Pastes _
  the Description at the Cursor in the open AmazonSale Word Doc.

   'Macro recorded 2/1/2008 by Mike

   ' Keyboard Shortcut: Ctrl+Shift+W

Dim lRow As Long
Dim lCol As Long
Rows(ActiveCell.Row).Cut
Windows("AMZ-GM Sold.xls").Activate
lRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row 'This gets the last row from AMZ-GM Sold.xls
ActiveSheet.Cells(lRow + 1, 1).Activate 'Add 1 to the last row for first blank row
ActiveSheet.Paste
Cells(ActiveCell.Row, 26).Copy ' Copy Z--- 26 = z



Dim WDApp As Word.Application
Dim WDDoc As Word.Document
Set WDApp = GetObject(, "Word.Application") ' Reference active document
Set WDDoc = WDApp.ActiveDocument
WDApp.Selection.PasteSpecial
WDApp.Visible = True 'This should leave Word Open
' Clean up
Set WDDoc = Nothing
Set WDApp = Nothing
Application.WindowState = xlMinimized
End Sub

I'm getting better at editing my macros but still having tough time with specifying variables / location. There does not seem to be the pleathra of info for word VBA as there is for Excel. Any Ideas or Help much appreciated. Thank You


This question generated 22 answers. To proceed to the answers, click here.

This thread is current as of May 22, 2014.


For more resources for Microsoft Excel