Dynamic macro's

E

Ekser

Hi,

Here's what i'd like to do:

I have a macro that gets data from the populated rabge in Excel an
transfers it into a Word document. This works fine with my test code
for one row.

What I'm trying to do, is that when this macro gets triggered i
'recognises' the selected row (1, 2, 3, 4, ...) and according to th
row number it populates my word document. Here's the code I hav
currently:

-Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.8")
appWD.Visible = True
Sheets("Template").Select
Range("A3").Copy
Sheets("Data").Select
Range("B3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False
Sheets("Template").Select
Range("C3").Copy
Sheets("Data").Select
Range("B4").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False

etc.


' Copy the data for the new document to the clipboard
Range("A1:B14").Copy

' Tell Word to create a new document
appWD.Documents.Add
' Tell Word to paste the contents of the clipboard into the ne
document
appWD.Selection.Paste
Range("B3:B14").Select
Selection.ClearContents
Sheets("Template").Select-


So, I would like those A3, B3, C3 ... from my sheet template to b
recognized dynamically - when the user selects a whole range.

How to do this?


Thanks
 
G

Guest

hi,
you can't. in code, you have to tell it what to select.
the code will not recognize selected data selected by the
user prior to the code running.
you will have to add code, telling it what to select based
on your criteria. and since you did not state what this
criteria is(other than "what the user selected"), i can't
help you on that part.
sorry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top