Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
mstuf mstuf is offline
Junior Member
 
Posts: 0
Default 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.
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add CC addresses in Macro Merge GeorgeA Mailmerge 1 June 23rd 09 10:35 PM
Can't Add Macro Shortcut Keys Matthew Mailey Microsoft Word Help 2 August 7th 07 03:28 PM
How do I add a macro to a document? Bobby New Users 1 July 30th 05 05:21 PM
Add/change headers with a macro Neron Microsoft Word Help 1 July 15th 05 07:26 PM
Add a new page in a form by using a macro??? La La Lara Microsoft Word Help 1 January 19th 05 05:41 PM


All times are GMT +1. The time now is 03:03 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"