Solved

Merge cells with VBA in an OLE object

Posted on 2007-04-06
7
751 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views 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 Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

729 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