Solved

Merge cells with VBA in an OLE object

Posted on 2007-04-06
7
746 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18865745
try

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

Expert Comment

by:Rey Obrero (Capricorn1)
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Connecting to MSSQL server from MS Access 5 49
Export to Excel 7 32
MS Access 2012, Split Form 2 38
How to properly refer to a form in the code below 2 20
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

792 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