• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 764
  • Last Modified:

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
0
UniqueData
Asked:
UniqueData
  • 4
  • 3
1 Solution
 
Rey Obrero (Capricorn1)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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now