Solved

Merge cells with VBA in an OLE object

Posted on 2007-04-06
7
735 Views
Last Modified: 2008-01-09
What is the syntax to merge two cells in an Excel OLE object on an Access form?

Thanks,

Michael
0
Comment
Question by:UniqueData
  • 4
  • 3
7 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 18865068
try
range("A1:B2").select  ' not sure about the address of the cell
selection.merge
0
 
LVL 7

Author Comment

by:UniqueData
ID: 18865559
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
 
LVL 7

Author Comment

by:UniqueData
ID: 18865574
ahh, i got it with your help.

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

thanks
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Author Comment

by:UniqueData
ID: 18865648
one more if you don't mind, what about centering the text after it is merged?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 18865745
try

.range(strRange).columns.HorizontalAlignment = xlcenter
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 18865764
or
.range(strRange).HorizontalAlignment = xlcenter
0
 
LVL 7

Author Comment

by:UniqueData
ID: 18865809
perfect, except access didn't understand xlcenter so I opened Excel's vba and found the value -4108

Thanks again
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now