Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Why can't I select when I'm setting up a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
REVA - 03 Jan 2006 17:02 GMT
I am trying to set up a macro that will Select Cells in a Table and then
Paste from the Clipboard.  I am not very good with Macros and am using the
Record feature to do the macro.  When I turn it on, it will NOT let me Click
in the cell where I want to start my paste.  Can anyone help?  This is soo
easy manually, and since I have to Paste the same info in several different
places, I want to be able to Macro it.  I am copying selected cells (across)
from Excel and pasting them (down) into a several Word tables within the same
document.
Kevin B - 03 Jan 2006 19:37 GMT
You can use the keyboard to select cells/rows in a table by holding down the
shift key, but the mouse click & drag method does not get recorded.

You can also programmatically select cells in a table with something like

   ActiveDocument.Tables(2).Cell(2, 1).Select

Which would select the second row, first cell in the second table of the
active document.

Hope this helps...
Signature

Kevin Backmann

> I am trying to set up a macro that will Select Cells in a Table and then
> Paste from the Clipboard.  I am not very good with Macros and am using the
[quoted text clipped - 4 lines]
> from Excel and pasting them (down) into a several Word tables within the same
> document.
AnneT - 04 Jan 2006 14:56 GMT
Reva and Kevin,

I am trying to do something very similar in Word.  I use macros in Excel,
and was very surprised to learn that you lose cursor selection with recording
macros in Word.  Kevin, thanks for  you post - i have several fields which i
need to update in tables, and by using your code, i was able to set up my
macro successfully.

Two questions as follow up
1.  I have my tables bookmarked to specify names for them.  Is their a way
to specify the bookmarked name, rather than just "Tables(#)".  For example,
one table is bookmarked as "TotalTable".  How would I code that?  I tried
both Tables("TotalTable") and Tables(TotalTable) - no luck.  If I can't use
the bookmarked name, is there a way to view the Word name/number for the
table -without counting the number of tables in the document and missing some.
2. In Excel I have created applications with macros assigned to buttons,
which are graphically embedded in the worksheet.  The user just selects the
button in the worksheet to run the macro - much easier and intuitive than
assigning the macro to a toolbar.  Does Word have the same capability?  I've
used the help menus, but didn't see that option.  I'm hoping....

Thanks in advance

> I am trying to set up a macro that will Select Cells in a Table and then
> Paste from the Clipboard.  I am not very good with Macros and am using the
[quoted text clipped - 4 lines]
> from Excel and pasting them (down) into a several Word tables within the same
> document.
Kevin B - 04 Jan 2006 16:22 GMT
You can select the bookmark with the first line of code, and then type
whatever text you want with the second line of code

   ActiveDocument.Bookmarks("Book Mark Name as a string").Select
   Selection.TypeText Text:="What you want to type."

FYI:  If you're going to be doing any real coding in Word I highly recommend
the "Word 2000 Developer's Handbook" by Guy Hart-Davis, published by Sybex.

This book is now out of print but I was able to get a copy of it from
Amazon.  It's a little pricey as books go, but it is most definitely worth it.

Happy coding...
Signature

Kevin Backmann

> Reva and Kevin,
>
[quoted text clipped - 27 lines]
> > from Excel and pasting them (down) into a several Word tables within the same
> > document.
Kevin B - 04 Jan 2006 16:36 GMT
I'm so A-D-D that I just zipped by question number 2.

You can place buttons in a Word document using ActiveX controls.  To access
these tools right click on any Word tool bar and select Control Toolbox
toolbar.

By default these buttons will print, and although you might be able to
supress the printing of these object, I don't know off the top of my head
what you would need to do to set this.   In Excel, when you right click on a
button one of the properties is PrintObject, a True/False property, but I did
not see this property associated with the button in Word.

I
Signature

Kevin Backmann

> Reva and Kevin,
>
[quoted text clipped - 27 lines]
> > from Excel and pasting them (down) into a several Word tables within the same
> > document.
AnneT - 04 Jan 2006 17:56 GMT
Kevin,

Thanks - I didn't think of "Bookmarks" as the object - I was trying "Tables"
and "Fields"!  I'm almost there - I have both an activex command button and
an image control in my document, both with the correct code to update the
fields.  Nothing seems to happen when I select the buttons - it doesn't
matter if the form is protected or not.  My macro works fine - on a toolbar,
and working.  The same code attached to an activex control does not.  I know
I'm missing something basic here.  I'm just using the "Word 2003 Inside and
Out" book - I'll look into the programming guide - but in the meantime, I
appreciate your help.  Any ideas of why the activex controls don't work?  
They don't generate any errors either - I just click and nothing happens.

> I'm so A-D-D that I just zipped by question number 2.
>
[quoted text clipped - 41 lines]
> > > from Excel and pasting them (down) into a several Word tables within the same
> > > document.
Kevin B - 04 Jan 2006 18:19 GMT
When you inserted your command button you were placed in design mode, did you
turn design mode off before attempting to run the macro.

The design mode toggle is on the the Control Toolbox, it's the button with
the triangle, pencil and ruler.

Signature

Kevin Backmann

> Kevin,
>
[quoted text clipped - 54 lines]
> > > > from Excel and pasting them (down) into a several Word tables within the same
> > > > document.
AnneT - 04 Jan 2006 18:57 GMT
Yes, I went out of design mode - and I tried the buttons with both form
protection on and off - no difference.  My macro on the toolbar runs with
either protection on or off.  I don't know why the code in the ActiveX
buttons won't work.  No error, nothing.  When I click the buttons, nothing
happens.  The code is the same as the macro- I just copied it over.  Do I
need to enable something in tools or in my document for ActiveX controls?  It
looks like the document is not recognizing that the code is there.  If I
purposely make an error in the code - I don't even get a runtime error.  
Thanks for your help - I really appreciate your time.

> When you inserted your command button you were placed in design mode, did you
> turn design mode off before attempting to run the macro.
[quoted text clipped - 60 lines]
> > > > > from Excel and pasting them (down) into a several Word tables within the same
> > > > > document.
Kevin B - 04 Jan 2006 20:22 GMT
Mmmmm.

Assuming that you have the button code assigned to the OnClick event, have
you tried just referencing your macro, which you know works, instead of
putting the macro code in the OnClick event?

Why don't you remove all the macro code for the OnClick event and replace it
with the name of your macro instead and see if that works.

Signature

Kevin Backmann

> Yes, I went out of design mode - and I tried the buttons with both form
> protection on and off - no difference.  My macro on the toolbar runs with
[quoted text clipped - 70 lines]
> > > > > > from Excel and pasting them (down) into a several Word tables within the same
> > > > > > document.
AnneT - 04 Jan 2006 21:34 GMT
Got it!!

I had to change my macro security level to run the code in the ActiveX
controls.  I don't really understand why the macro ran as a macro in the
"normal.dot" template and not as code in the specific document,  but it
didn't.  I knew something was different because it didn't even give me error
messages.

Thanks so much for all your help and persistance!  

Happy New Year - Anne

> Mmmmm.
>
[quoted text clipped - 79 lines]
> > > > > > > from Excel and pasting them (down) into a several Word tables within the same
> > > > > > > document.
Kevin B - 04 Jan 2006 21:52 GMT
Glad to hear you finally got it working, and wouldn't you know it would be
something that obvious.  Never fails...
Signature

Kevin Backmann

> Got it!!
>
[quoted text clipped - 91 lines]
> > > > > > > > from Excel and pasting them (down) into a several Word tables within the same
> > > > > > > > document.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.