Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Need Help to Add to Macro
Good Evening -- Newbie Here ( Sophomore / Freshman ) -- Thanks for Looking. I realize this is a WORD forum. My Question is a Word VBA Question as it applies to an Excel Macro that moves data to a word document.
I am using Office XP - 2002. I have a Working Excel Macro that has evolved through time from a Recorded Operation. Features have been added with the gracious help of others , Google, experimentation and LUCK. Some of whats there exceeds my understanding. I've used it 1000's of times in the last couple years. It saves time and provides considerable error reduction. I would like to add another routine to it and would really appreciate help. This Macro is run from a chosen active cell in an Excel Workbook Named "AMZ-GM-Combine.xls". It Highlights the entire row that the active cell is in and Cuts the row from the Workbook. It pastes that row into the first open row in Excel Workbook "AMZ-GM Sold.xls" . From that Pasted Row, it Copies Cell Z. It activates an already open Word Document and Pastes "Special", that copied text, to the position of the Cursor. It leaves the Word Document Visible. Here's my working Excel / Word code. [Code} Sub OpenToSold() 'Macro recorded 2/1/2008 by Me ' 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 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 leaves Word Open ' Clean up Set WDDoc = Nothing Set WDApp = Nothing Application.WindowState = xlMinimized End Sub [/code] I would like to add one more job to this Macro. I would like to Also Copy the Contents of Cell S from "AMZ-GM Sold.xls" to the same open Word Document and Place it in the First Blank Line after the first row that contains more than 10 dash characters in a row. (--------------------) I'm puzzled about how to initiate a Second operation. I'm especially puzzled about how to designate that position in the word document. I assume that the postion ( First Blank Line after the first row that contains more than 10 dash characters in a row ) must be defined as an Object. Mail Merge is not an option at this point because of other related macros for other segments of the routine. Thanks for Looking. Any Help Appreciated. |
#2
|
|||
|
|||
Quote:
I shop here in Eugene Oregon area but find that most books on Word VBA / Macros skirt my needs. Most are dealing with Message Boxes -- Address Manipulation, reformatting documents etc. I found a reference guide about modifying appearances of pages etc and other functions that I didnt even know existed. So... its seems that I have found to exist, is Too Basic - off topic or Way over my head. I need more info on Defining Objects & specifying locations in Word Documents. The way I see it, I need to ID a location in a Word Document based on a named object. In Excel its pretty simple but there doesnt seem to be much info about it for Word. I also need help to figure out the best method to add this extra routine to the existing Macro. Run it as a separate macro called from within the existing macro or as added code to the existing macro ? I put this project on the back burner for a while but now trying again to gain the knowledge of how to complete it. Any Info appreciated -- Thanks for Looking |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Add CC addresses in Macro Merge | Mailmerge | |||
Can't Add Macro Shortcut Keys | Microsoft Word Help | |||
How do I add a macro to a document? | New Users | |||
Add/change headers with a macro | Microsoft Word Help | |||
Add a new page in a form by using a macro??? | Microsoft Word Help |