Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Evening all, As always what I thought would be a nice bit of mental exercise has evolved into some monster that delights in my frustration and on-coming headache:( . What my little bit of code is trying to do is as follows: 1. The user selects the cells (using the standard Ctrl button and mouse-click method) which are to be printed in a pre-constructed labels document in Word 2. The code executes when a control button is activated and registers the selected cells as an array using the selection object(?) and then cycles through the array members adding each to its own label in the document. Does that make any sense? Basically I'm trying to turn selected cells into an array and process them that way. Well, to my delight:) the code worked perfectly until I tried selecting just one cell (i.e. one record) to print. It seems that VBA won't recognise one-selected cell as an array ![]() Further testing proved that a non-contiguous selection of cells also won't be recognised as an array ![]() I'm at a bit of a loss now and its not a facility I can do without. Any help will be greatly appreciated. Thanks Tris ![]() Selection of code below: Private Sub CommandButton1_Click() Dim Outputs As Variant Dim i As Integer Record_a = Selection.Value Dim Word As Word.Application Set Word = New Word.Application With Word ..ScreenUpdating = False ..Documents.Open Filename:="C:\Documents and Settings\Label1.doc" ..Visible = True For i = LBound(Record_a) To UBound(Record_a) With .Selection ..TypeText Text:=Record_a(i, 1) ..MoveRight unit:=wdCell, Count:=1 End With Next i ..ScreenUpdating = True End With Set Word = Nothing End Sub -- Tristan ------------------------------------------------------------------------ Tristan's Profile: http://www.excelforum.com/member.php...o&userid=34061 View this thread: http://www.excelforum.com/showthread...hreadid=541967 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Add Permission did not work in "Allow User to Edit Ranges" | Excel Discussion (Misc queries) | |||
Delete non-contiguous selected rows | Excel Programming | |||
summing non contiguous ranges | Excel Discussion (Misc queries) | |||
Adding Non-Contiguous Ranges | Excel Discussion (Misc queries) | |||
Delete a selected area from a non-contiguous range | Excel Programming |