Merge cells with VBA in an OLE object

What is the syntax to merge two cells in an Excel OLE object on an Access form?

Thanks,

Michael
LVL 7
UniqueDataAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
try
range("A1:B2").select  ' not sure about the address of the cell
selection.merge
0
 
UniqueDataAuthor Commented:
I tried the following:

    With Me.Spreadsheet0.Object.Sheets(1)
        .Cells(1, intColNum) = strLotNumber
        .Cells(2, intColNum) = dtInspectionDate
        .Cells(3, intColNum) = "Actual"
        .Cells(3, intColNum + 1) = "Target"
        strRange = "A" & intColNum & ":" & "B" & intColNum
        .Range(strRange).Select
        .Selection.Merge
        strRange = "A" & intColNum + 1 & ":" & "B" & intColNum + 1
        .Range(strRange).Select
        .Selection.Merge
    End With

but on the line .Selection.Merge i get the error: 'Object doesn't support this property or method'.

Again, this is an OLE object within an Access form if that matters.

Michael
0
 
UniqueDataAuthor Commented:
ahh, i got it with your help.

I just changed .range(strRange).select
to
.range(strRange).Merge

thanks
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
UniqueDataAuthor Commented:
one more if you don't mind, what about centering the text after it is merged?
0
 
Rey Obrero (Capricorn1)Commented:
try

.range(strRange).columns.HorizontalAlignment = xlcenter
0
 
Rey Obrero (Capricorn1)Commented:
or
.range(strRange).HorizontalAlignment = xlcenter
0
 
UniqueDataAuthor Commented:
perfect, except access didn't understand xlcenter so I opened Excel's vba and found the value -4108

Thanks again
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.