In Word, Check # Of Cells In Current Row, Then Select First Two Cells In Row
I'm trying to do a little VBA subroutine that will run in Word 2003 (VB 6.5), when insertion point is in a table. What I want it to do is: * Confirm the insertion point is in a table * Go to the first row in current table * Check if the number of cells in that row >= 5 * If so, merge the first two cells in that row * If not, go to the next row * Continue checking (and merging, if appropriate) to end of the table
I know how to check if insertion pt in in a table and how to merge two cells once they're selected, but am totally stumped on the middle part -- the real heart of the matter... (I've tried a bunch of things, using VBA Help info as a guide, but to no avail.)
* How do I determine the number of cells in the current row? * How do I select the first two cells in current row?
Really would appreciate any help/guidance.
Edited by - topaz2 on 1/20/2007 8:44:46 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Mshflexgrid: Get Values Of Cells Or Row Numbers That Relate To Merged Cells
I am using a mshflexgrid and the first 2 columns are merged. So I have 8 rows all with a value for a material code and a description that is identical and for those 8 rows I have different percentages for all my different sizes. Now when a user clicks on a row I want to get all the percentages and sizes for the material. Is there any way to get the start and end rows for a merged cells so that I can get the adjacent values that apply to the current material.
Any help is (as always) appreciated...
"The answer is out there, Neo, it’s looking for you. And it will find you, if you want it to."--Trinity to Neo
Filling Cells With Formulae That Refer To Data In Other Cells
I'm trying to create a macro that uses a DDE function. I need to fill a row with formulae that take in information from other cells, and combine with command "winros".
For instance, given 4 colums and 3 rows (the following is meant to represent a spreadsheet):
Code:
[]ABCD
1MSFTMSFTIBMIBM
2LastOpenBidAsk
3
I need to fill out Row 3 with formulae that combine the values in the rows above it. e.g., Row 3, Column A would show:
=winros|MSFT!'Last'
I need to combine =winros| with the value in cell A1 (two rows above), then with !', then with the value in cell A2 (one row above), then with '
However, I do not know how to do this How do I fill a row of cells with formulae that refer to other cells?
Filling Empty Cells In Column With Former Cells Data
What I am trying to do is shown below
Before;
Alpha One
[Blank Cell]
[Blank Cell]
[Blank Cell]
Beta Two
[Blank Cell]
[Blank Cell]
Charlie Three
[Blank Cell]
Delta Four
Epsilon Five
[Blank Cell]
After;
Alpha One
Alpha One
Alpha One
Alpha One
Beta Two
Beta Two
Beta Two
Charlie Three
Charlie Three
Delta Four
Epsilon Five
Epsilon Five
It would be great if I can select the range to be processed for the column so that it doesn't go loopy. Any help would be greatly appreciated.
Cheers
KiwiSammy
Looping Through Cells For Empty Cells Dynamically - Excel VBA - Need Help
Hi,
I need to run a SQL like 'Select * from xyz where xyz.column1 in {all entries from cell A1: A10}
The criteria here - cells in column A would be loaded dynamically and I would not know how many columns are there (it could be say, A1 to A10 or A1 to A 40). So basically I need to start at A1 , increment column by 1 and look for empty cells. When an empty cell is found, all values from A1 to the one before the empty cell would be included in the where query.
i would like to achieve this and would need your help in getting this done.
Thanks.
-VS
Select Cells
Hello,
I have two colums
A B
1 10
2 20
3 30
4 40
5 50
60
70
and this code
Code:
Private Sub CommandButton1_Click()
Dim n As Long
n = Range("A65536").End(xlUp).Row 'n = 6 in this example.
Range("B" & n + 1).Select
End Sub
how can I select the range "B" & n to "B100" ?
I have tried
Range("B" & n + 1 : "B100").Select but is does not work
Thanks in advance,
Jaap.
Move Non-formula Cells In A Range Up 3 Cells
Hi,
I want to write a macro to move a range (D34:L44) of cells up by three rows in a excel sheet if
a) they do not contain a formula
b) if they are non-zeros and numeric
I need to repeat this for all worksheets (about 30) that start with the letter 'A' , 'C', or 'P'
I would like to be able to execute this by macro, saving a lot of manual boredom!!
Any idea's ?
Thanks in advance
Combining Text In Cells Based On Other Cells
I have the following problem that I need to solve and VB seems the only way to do it.
I have 3 columns of information in Excel, I need to combine the text in column C based on if the information is the same in column A and then the same again in column B.
example: if a has 3 cells with the number 1 in them and column B has 2 cells with # 5 in them then Column C for the 2 matches needs to combine. and I need to add a comma after each string of text.
Thanks for your help with this.
James
Merge Cells Depending On Cells' Contents
I have two columns like
column D E
line 5 ABC 1
line 6 [empty] 2
line 7 [empty] 3
line 8 [empty] 4
line 9 ABC 1
line 10 [empty] 2
line 11 [empty] 3
....
line 60 ABC 1
line 61 [empty] 2
line 62 [empty] 3
line 63 [empty] [empty]
line 64 [empty] [empty]
....
I need to merge each cell containg text (ABC) with the empty cells below. My goal is to have some big cell with (ABC) in column D and all the cells with (1), (2), (3) in column E ... so that when I filter on column E, I don't loose the info on clumn D. (i.e. if I filter looking for (2) on column E, I will not be able to see the corresponding text (ABC) for each (2) value found by the filter)
Some facts:
* The number of empty cells below each text cell (ABC) is not constant - can be 0 as well as 100.
* The number of total text cells in column D is not constant.
My problem is that I do not know visual basic at all...
What I was thinking of in terms of algorithm is:
begin
variable CELL var1
variable CELL var2
var1 = D5
var2 = D6
while(var1 is not empty)
selection.add(var1)
while(var2 is empty)
selection.add(var2)
var2.move_one_cell_down()
end while
selection.merge
var1 = var2
var2.move_one_cell_down()
end while
end
Can it be translated into VB???
Thanks!
Edo
Column Select+ 2 Cells
I am sure this is easy, but I am trying to select all data in a column plus the two empty cells immediately underneath. Basically, what it all adds up to is that I want to select a range of cells (in a column) and move the whole thing down 2 cells.
Any help would be great
Insu
How To Select A Range Of Cells
I am converting VBA code in Excel to Visual Basic. I am having a problem when it comes to selecting a range. The VBA code is:
Range("L9:O2000").Select
Selection.Locked = False
So, in VB, what command would I use to select the above range?
Any help would be appreciated, as this is the last command I haven't been able to modify correctly.
Excel- Select All Cells Problem
These methods I've used result in a "Runtime Error 9: Subscript out of range" error. I'm trying to select all the cells in a table to make a chart. It works fine sometimes...here are the ways I've used:
Code:
ActiveChart.SetSourceData Source:=ActiveWorkbook.Worksheets(i).UsedRange, PlotBy _
:=xlColumns
' and also tried
ActiveChart.SetSourceData Source:=ActiveWorkbook.Worksheets(i).Range("A1").CurrentRegion, PlotBy _
:=xlColumns
I also tried both of above using ActiveSheet instead of ActiveWorkbook.Worksheets(i) and I get a Runtime 438 error- Object doesn't support this method or property. I've used
Code:
' some code above
' Determine the size of the range and store it.
Set xlSourceRange = _
xlWrkbk.Worksheets(1).Range("A1").CurrentRegion
' Create a new chart.
Set xlChartObj = xlApp.Charts.Add
' Format the chart.
With xlChartObj
' Specify chart type as standard clustered.
.ChartType = xlColumnClustered
' Set the range of the chart.
.SetSourceData Source:=xlSourceRange, PlotBy:=xlColumns
' some code below
from Access and it works with some charts. That's why I went directly to Excel to see what the problem was, but now I got this other selection problem.
Need help, please.
How Can I Select Only Part Of A Cells Contents
How can I in Excel select only part of a cells contents (Or better, delete the parts I don't want) based on certain criteria. I.e. If I have many numbers in a cell each preceeded with ~ apart from lets say 2 numbers e.g. ~1 ~2 ~3 4 5 ~6 ~7 how can I automatically delete all the numbers preceeded with ~ to be left with in this example 4 5?
Cells.find Or Select Case Or If
Can anyone tell me which is best for this purpose?
Range includes several names in column A and Actual grades in column B and Predicted grades in column C. D contains a rate.
Grades are typically A1, A2, A3, B1, B2, B3, C1, C2, C3 for Actual and Predicted Grade. This data is updated monthly.
The results are refreshed onto a pivot table held on a master sheet.
Pivot rows show Actual grades and pivot column displays the Predicted grade.
Each row and column must show each possibility of the grades in order which is why I'd like to run a macro to check which grades are not included in either of the two grade types - Actual/Predicted.
Then, insert 'dummy' lines to the raw data range so that the pivot table accounts for that grade even without a rate figure.
So, in summary: Search the raw data sheet and check if any grades are missing.
If any are missing then insert the missing grade into columns B and C to enable them to be listed in the pivot rows/columns.
Which method would you advise is best?
(Proving kinda exhausting to search the online help, forum threads and my books if I'm not even sure which method is relevant for my task).
Any guidance would be much appreciated. Thanks.
Cells([D65536].End(xlUp).Row + 1, 4).Select
Code:
Cells([D65536].End(xlUp).Row + 1, 4).Select
This code works perfect if I execute it from a commandbutton in a form, BUT if I try to execute it by a commandbutton created on the spread sheet by use of button from Control Toolbox it does not work at all.
Error message seems to be that xlUp read a value like -4152.
How can I solve it?
Thanks
Select Range Of Cells Same Contents
How can I select a range of adjacent cells having the same content?
The purpose is to select a group of cells to export to a new file: a new file for each group of same rows having the same content in the first cell of the column.
Thanks
Select Non-blank Cells In Excel Via ADO
I'm trying to query an excel spreadsheet for a list of products but when i run across a blank cell the record set spits out an illegal use of null error. Any one know a work around?
Second, I understand SQL reasonably well yet the syntax for excel SQL is a bit lacking in its robust functionality, I don't really expect anything different. I get the named ranges and even unnamed ranges but is there a way to use WHERE or any other clauses?
Select Multiple Cells In MSHFlexGrid
I have a program and need to select multible cells in a HSHFlexGrid.
I have it working the the folloing code with some issues
Here is what I want I want to select mulitble cells but only one cell per col I must be able to know what cells are picked later.
The problems are is there a better way to set the cellbackcolor? Stepping thou all cells take long on some larger grids. I have the backcollor changed depending on what is in there so I can not globaly set all backcolor.
Is there a better way to do what I am trying?
Is there a faster way to clear the cell backcolor?
VB Code:
Dim multi As BooleanDim TargetSelect(200) As Integer ' max cols possible Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)' do not want row or col 0If MSHFlexGrid1.MouseCol > 0 And MSHFlexGrid1.MouseRow > 0 Then If Button = vbLeftButton Then Dim lngColor As Long If Shift = vbCtrlMask Then ' Only one want cell allowed per col If TargetSelect(MSHFlexGrid1.Col) < 1 Then lngColor = MSHFlexGrid1.BackColor If MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColor Then lngColor = MSHFlexGrid1.BackColorSel TargetSelect(MSHFlexGrid1.Col) = 0 End If With MSHFlexGrid1 .CellBackColor = lngColor ' save what cell is marked in this col TargetSelect(.Col) = .Row End With mulit = True End If Else If multi = True Then lngColor = MSHFlexGrid1.BackColor With MSHFlexGrid1 tmprow = .Row tmpcol = .Col ' Take too long! For a = 1 To .Cols - 1 .Col = a TargetSelect(.Col) = 0 For b = 1 To .Rows - 1 .Row = b If .CellBackColor = .BackColorSel Then ' Set all cell back to normal .CellBackColor = lngColor End If Next b Next a .Row = tmprow .Col = tmpcol End With End If lngColor = MSHFlexGrid1.BackColor If MSHFlexGrid1.CellBackColor = MSHFlexGrid1.BackColor Then lngColor = MSHFlexGrid1.BackColorSel TargetSelect(MSHFlexGrid1.Col) = 0 End If With MSHFlexGrid1 .CellBackColor = lngColor TargetSelect(.Col) = .Row End With multi = True End If End If End IfEnd Sub
Select A Range Of Cells In Excel
Why do I keep getting this error when I try to select a range of cells in my worksheet?
Run-time error '1004':
Select method of Range class failed
Range("A13:K20").Select is the erroneous line.
Private Sub OptionButton1_Click()
Worksheets("Data").Activate
Range("A13:K20").Select
Selection.Copy
Worksheets("Test Plan Worksheet").Activate
Range("B27").Activate
ActiveSheet.Paste
End Sub
Check Cells Before Division By Zero
I want to make sure of no divison by zero error messages
I am doing division on a mshflexgrid like this:
with grid
.textmatrix(2, 12) = .textmatrix(2, 11) / .textmatrix(2, 9)
some of the cells maybe empty and some maybe formated as currency with a dollar sign
is this the best method:
vb Code:
If val(.textmatrix(2, 11) <> 0 then If val(.textmatrix(2, 9) <> 0 then .textmatrix(2, 12) = .textmatrix(2, 11) / .textmatrix(2, 9) else textmatrix(2, 12) = "" end ifend if
would this code be appropriate?
Want To Select Cells From Excel To Vb And Convert Them To An Array
sir,
i am in a fix. i dont know much vb. so please help me to find solution to my problem. my problem is that i want to access cells from excel and want to convert them into an array. is it possible. and how to do that. from my vb interface i want to open the file/workbook and select the cells that i want to make them an array and use them in my program, as input
please help me sir
thanks
pradeep
Select Cells In The Same Column Till The Last One With Data
Re: http://www.xtremevbtalk.com/t125574.html
This post was very, very helpful to me. Thanks.
I combined what you stated and combined it down to one line for myself.
Code:
Range("B2", Range("C65536").End(xlUp)).FillDown
This fills down from B2 to the last cell with data in column C.
Select Cells In The Same Column Till The Last One With Data
I was trying to select cells in the same column from a cell with data to the last cell with data, the cells in between are either all empty or all with data. As my row numbers change everyday, I have to find a way to choose the range automaticlly.
Can anyway help me on this?
I know how to locate the last cell with data, however, I don't know how to choose the range especially the row numbers change everyday.
Thanks.
Cells Select, And Multi Format Activity
Hi Guys,
I tried to record a macro which opens an Excel workbook, selects all the cells of the worksheet, and delete them.
It seems that the cells.select, or Range("a2:l56").select doesn't work.
Do you have any idea guys?
Also, how can I run Word from Excel, and open a Word file, and run a macro in this Word file?
Thanks for your help
Select A Range Of Cells In Excel. Just Learning And Need Help.
Why do I keep getting this error when I try to select a range of cells in my worksheet?
Run-time error '1004':
Select method of Range class failed
Range("A13:K20").Select is the erroneous line.
Private Sub OptionButton1_Click()
Worksheets("Data").Activate
Range("A13:K20").Select
Selection.Copy
Worksheets("Test Plan Worksheet").Activate
Range("B27").Select
ActiveSheet.Paste
End Sub
Select/highlight Fixed Cells In Msflexgrid
I am using msflexgrid for displaying data from the database. The first two columns in the grid are fixed. My problem is that when I select a row in a grid the fixed cell does not get highlighted.
regards,
Atul
Select Range Of Excel Cells In Flexgrid
I've connected an excel spreadsheet to a flexgrid but don't know the sql syntax to select a specific range of cells.
I know I can use SELECT * FROM [Sheet1$] but I need to limit the range further, ideally selecting the first four columns and tjhe full range of rows that contain data (the number of rows will increase as the spreadsheet expands).
Any help is much appreciated.
Select Data From Specific Cells (Now Resolved)
Hello
I am trying to find out if it is possible to input data from specific cells from an Excel spreadsheet to text boxes. The spreadsheet will always be the same format but name will change depending on the user.
Example
My Spreadsheet.xls
His Spreadsheet.xls
Basically what I would like to do is
Textbox1.text = cell A4
Textbox2.text = cell B6
and so on...
Can this be done and could some one help me get started
Thanks
Bob
Edited by - Bob Taylor on 7/20/2003 9:09:49 AM
Select Cells In Datagrid And Display In Textboxes
I have two forms. On "Form1" I have a datagrid view that I have set up so that when the user doubleclicks on a row my second form "Form2" opens and displays another datagrid view showing more detailed information, Im really pleased with this and it works perfectly. My question is, how would I code it if I wanted the second form to display the information in textboxes instead of the datagrid??? Im using Visual Studio Express and an SQL database
Edited by - Dottj on 5/23/2007 8:16:44 PM
How To Select A Range Of Cells, And Make A Sort Into?
Hi, my macro creates a Pivot Table.
The Table is created starting from a cell, that I can define as variables:
Code:Dim RowPivot As Integer
Dim ColPivot As String
ColPivot = "b"
RowPivot = 7
So I know where the table starts.
After, I look for the"Grand Total" string in the second row, to determine how the table is large (it depends by how many columns are selected).
Again, I look for the "Grand Total" in the first column to determine how the table is long.
For example:
Code:Columns(ColPivot).Select
Selection.Find(What:="Grand Total", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
y = ActiveCell.Row - 1
And similar for the x.
And now, I have to select only the data, excluding the first 2 and the last row.
The problem is that Sort needs a key (must be any elements of the last column) to make the sort, and this reference must be in "RyCx" format to specify Row and Column, in number.
look at this:
Code:Range("b9", "I29").Select
Selection.Sort Key1:="R9C9", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
ActiveWindow.ScrollColumn = 2
this makes a rigid selection and sort, and "R9C9" is manual inserted in the code, how to make it a variable?
How to convert the cell below the upper "Grand Total" in RyCx format?
Do you know a more elegant method to make this?
Many, thanks, Alessio
Edited by - skizzot on 6/18/2003 7:38:57 AM
Excel Macro - How To Select Used Cells In A Column?
Hello!
solutin is in the last post
I'm trying to workaround this problem: http://support.microsoft.com/defaul...kb;en-us;815277
this changes data in a selection to make it REALLY of text type, provided the cells were already text type.
If anyone knows another way to achieve the same result, that is welcome too. (convert mixed numeric and text data in the same column to only text data).
This is NOT achieved by going to Format -> Cells -> text
Although this is a required previous step for the method in the link above. The numbers are only stored as text once a space is entered before the number in the cell. We can delete the space later and the number will remain stored as text.
So,
I need a macro to do the following: select used cells in a specific column.
I need to select column "values" but not the entire column, only the used rows (it is possible that there are empty cells in this column, that should not matter, I need to select the cells if there is a corresponding non-empty cell in column "dt")
for example:
Code:
column a | column b | dt | column x | values | column z
....a....|....b.....|.1..|....x.....|...123..|....z....
....a....|....b.....|.2..|....x.....|........|....z....
....a....|....b.....|.3..|....x.....|...456..|....z....
....a....|....b.....|.4..|....x.....|........|....z....
here i would need to select 5 cells from column values, counting title cell
I already know that changing data type is achieved with:
Code:
Selection.NumberFormat = "@"
all I need now is select the cells I want to change...
Hope anyone can help me
Cheers
Check Boxes Linked To Cells
HI,
can anyone tell me a quick way of setting up check boxes that are linked to cells as i have a template that has 400 rows and 30 columns of check boxes available, but doing this manually could be a nightmare....
anyone????
thanks
Check Three Cells, Combine Them And Copy
Hi,
I have the following problem.
I have a lot of data in one sheet, containing modelcodes, optioncodes and colorcodes. Here´s what i want to do:
I want to check the first model/option/color combination (all different cells) with the other (same) combinations. After this is done it (the whole row)needs to be copied to another sheet (not existing yet, has to be created i.e. Sheet1). Then, the next model/option/color has to be checked and moved to another sheet...and so on.. ´till end of file..
The number of combinations may be up to 100 different combinations, that's why the combination has to be dynamic (and not entered and compared).
Can anyone help me?
Thanks!
Difference Between Cells.value And Cells.formula?
Hello, Everyone,
I used cells.value and cells.formula interchangely. would someone be kind to let me know the difference? and which is faster process? What's needed to notice?
Thank you very much!
Charlie
How Do I Get A Macro To Select A Cell Depending On Another Cells Data
this problem may be a simple one but as im not very good in visual basic i cannot think of a function to use.
here is an example of my problem.
I have a cell number in one cell.
Cell G1 has the data D5 in it.
And i need a macro to select cell D5 by using the info it found in cell G1.
Sorry if that isnt very clear but i cant think of any other way of explaining it. please help.
VBA Excel Select Cells In R1C1 Type Method
Hi People.
I was wondering why the following code is erroring out:
For I = 2 To 8
For J = 3 To LastRowColA
If PBNum = Sheet1.Range(Cells(I, J), Cells(I, J)) Then 'ERROR LINE
Counter = Counter + 1
End If
Next J
Next I
I am trying to reference a single cell at a time which works when I put in the numbers Sheet1.Range(Cells(1,2), Cells(1,2)), I need to change columns and rows hence the need of a couple of For loops.
The command doesn't seem to want to accept column or row #s as arguments.
Any suggestions?
Thanks in advance, DAVE
Excel: Check Values Between Two Cells On Different Sheets
In Excel I currently have 4 sheets, and one problem that I have encountered is this:
I have Cell B1 in Sheet4 as a setting.
This setting is a value that will be checked against in all cells in G column (except G1) in Sheet2.
Whenever a number is changed in column G I want Excel to see whether this number is less than Cell B1 in Sheet4 and if it is then a MsgBox should pop up.
I'm not too sure how to do this, so could someone advise me please? If you are not sure what I mean just post and I will try to explain it again.
Check If Excel Sheet Has Errors In Cells
Hi All
Does anyone know the correct way to check if there is an error in an Excel worksheet?
Code:'e.g. Assign a variable to the value in Cell A1 of a worksheet
strValue = XLRange.Value
'Will work fine unless there's an error in the cell (e.g. #DIV/0!)
'where you'd get a Type Mismatch error
Could do On Error Resume Next before each line but I've got lots of them and I think it might make the code look messy.
Thanks
Tee
Mouse-(down, Move, Up) Events To Select Cells Both Outside And Inside The Picturebox
I have a big picturebox (say picture1) and a smaller picturebox (say picture2) on top of picture1.
I am discretizing (dividing) the picture2 into subdomains (or cells). Then I am using mousedown, mousemove, and mouseup events to select a portion of cells and also recording which cells are selected (cells are stored in array with their physical locations known).
Things are working great as long as I stay inside picture2. I have been trying various ways to select the cells when I click and move from outside the picture2 box (while inside picture1) and then end either inside or outside the picture2 box. Similarly start inside the picture2 box and end outside.
Is there an easy way that I can't think of in order to achieve this?? Let me know if you want me to explain in further detail.
Thanks in advance,
Yogesh
Select/copy/paste Cells Based On Today's Date
Thank you in advance to anyone who can pass on the gift of their script to me on this one. i work in a firm full of IT developers & support, admittedly whose expertise isn't in VB, but nonetheless you'd of thought one of them could answer this one.
I have a long macro already recorded in excel. in Column A of a particular worksheet is every work day from today to end 2009. Based on formulas contained in each corresponding cell B,C,D & F, values appear if today's date = the date in column A. I want to tell the macro at the very last step, to copy/"paste values" these cells based on selecting only cells B,C,D & F in row = today.
at the moment, 4-Mar-08 is in cell A 130 & the macro will continue, tomorrow to only copy/paste B130,C130,D130,F130 even though the values will be generated in row 131 tomorrow. the data input worksheet changes daily which is why i need to 'lock in' these end of day values with a copy/'paste values' finish to each day.
Hoping someone out there can help me.
Thanks a lot to that person,
Brian.
Word Tables And Cells
try recording a macro and looking at the VBA code:
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:= _
4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
Active Cells Below A Word
Hi Experts,
Just learning VB.
I have a cell say "B2" with content MSC. I want to know how many active cells (non blank cells) are present below this word MSC.
What syntax will I use.
Regards
Nevil
Size Of Cells In Word Table
I have a word document with a table and a few cells in it. I am using late binding in a VB programme to insert data into this word form because I have users with different versions of Word on their computers, hence late-binding is the only way to ensure that things work OK.
My problem is this: I have one particular cell on the form which is use to enter a "request" as typed in onto an entry form by the user. This request can have up to 5 different sections to it, and each section can be from 0 characters to 510 characters long.
I need to keep the cell height at an exact size in order for everything to print out properly. If the user adds a lot of information into the request field, then the bottom few lines of the request won't be seen on the print out. How can I find out if the text in the request will be too big for the cell? Once I know this, I can then split the request down into two parts and print out half the request on one form, and the other half on a new form.
I can't use the "computestatistics" methods because VB tell me that the wdStatisticCharactersWithSpaces "variable is not defined" (presumably because I'm using late-binding methods).Does anyone have any other ways of doing this please?
Merging Cells In A Table In Word With VB6 (not VBA)
Alright, so I've nearly finished up a small program that takes information from an excel spreadsheet and copies the relevant information into a word table that is created on the fly. However, I've having a real difficulty with merging cells in word. Basically, I have situations where for a single column, up to four rows of information need to be merged, and within the same column there are unmerged cells. (for example, if X are merged cells and Y are unmerged, something like this)
X
X
Y
Y
X
X
X
X
Y
etc.
I've created a 2D array that has numerical values in it to match which columns in my table need to be merged, but its just the merge command that I can't get to work.
This is what I'm using to actually merge cells.
Code:
With wdTable
.Cell(currRow, nIndex).Merge (.Cell(currRow + currDepth, nIndex))
End With
But I get an incompatible type error. What am I doing wrong?
Working With Merged Cells In Word
I'm making a converter from Word to another format and came across a problem of identifying the merged cells in tables.
I can recognize a row which contains merged cells by finding the largest ColumnIndex in a table and comparing it with a ColumnIndex of a last cell in a row.
But how do I determine, which cells are merged?
If there are only a few rows with merged cells then I can just step a row up or a row down and check if the ColumnIndex has changed. But if there are several consecutive rows with merged cells, then I cannot do this.
Formatting Excel Cells From VBA-Word
Hello,
I'm running into a problem that probably has an easy answer. I'm naming files with a date the user provides. On the form I can control the format of the date to look like mm-dd-yy, but when I save my data to an excel file it changes the formatting to mmddyy. I use that date to name files so the is creating problems. could anyone give me an example of formatting a specific cell to save the date in mm-dd-yy format?
Thank you.
Kev
Manipulate Text In Ms Word Cells
This is my first vb code. i keep getting error 448. I simply want to modify the text in the cells in column one to shorten them by 3 characters.
Set aColumn = ActiveDocument.Tables(1).Columns(1)
i = 1
For Each aCell In aColumn.Cells
c1 = aCell.Range.Start
c2 = aCell.Range.End - 3
Set myRange = aCell.Range.Text(Start:=c1, End:=c2)
aCell.Range.Text = myRange
i = i + 1
Next aCell
The error occurs with the set myRange line. Help.
Word Macro - Splitting Cells
When I do the following line in Visual Basic to interact with Word:
oSel.Cells.Split numRows:=1, NumColumns:=2, MergeBeforeSplit:=False
It behaves differently when I set Word invisible than it does when I set Word visible. When visible it splits the cell where the cursor is at (which is what I want), but when invisible it makes a new column for that row tagged on at the end of the row. Why is this and how can I control it?
Need To Set Specific Cells In A Word Table To Read Only
Hello!
I am a VB developer that was suddenly thrust into the situation of having to make some changes to some word templates that are populated from a CRM package.
The request that was put before me was to set up a table in a word template where some cells will be auto populated and others need to be set to read only.
If this is possible, can someone please point me in the right direction?
Many Thanks :-)
|