Solved

Merge cells with VBA in an OLE object

Posted on 2007-04-06
7
742 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware 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 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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 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