I'm a beginner to moderate programmer who's fiddling around with automating
Excel, in particular after being able to have the user fill out a form and it
then generate the workbook. I can't quite figure out how to get it to Merge
cells together - I've found how to do it (I think) but can't nut out the
syntax. Any help with this would be much appreciated (I've tried looking for
online tutorials, but the ones I've found never touch merging).
Cheers,
Damian A. 3 25314
A trick I learned that works with most Microsoft products is to go to
Tools->Macros->Record->Record New Macro and then do whatever you are trying
to figure out what to do. When you view the macro, you then have the sytax. I
don't have .Net at home (so it's in VB, sorry), but try something like this:
Range("A1:B1"). Select
With Selection
.HorizontalAlig nment = xlGeneral
.VerticalAlignm ent = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
I hope this helps.
Susan
"Damian Arntzen" wrote: I'm a beginner to moderate programmer who's fiddling around with automating Excel, in particular after being able to have the user fill out a form and it then generate the workbook. I can't quite figure out how to get it to Merge cells together - I've found how to do it (I think) but can't nut out the syntax. Any help with this would be much appreciated (I've tried looking for online tutorials, but the ones I've found never touch merging).
Cheers, Damian A.
Hi Damian A.
Try this out.
Excel.Applicati on xl = new Excel.Applicati onClass();
Excel.Workbook wb = xl.Workbooks.Ad d(Excel.XlWBATe mplate.xlWBATWo rksheet);
Excel.Worksheet ws = (Excel.Workshee t)wb.ActiveShee t;
ws.Cells[1,1] = "Testing";
Excel.Range range = ws.get_Range(ws .Cells[1,1],ws.Cells[1,2]);
range.Merge(tru e);
range.Interior. ColorIndex =36;
xl.Visible =true;
Cheers,
Kids
"Damian Arntzen" <Da***********@ discussions.mic rosoft.com> wrote in message
news:78******** *************** ***********@mic rosoft.com... I'm a beginner to moderate programmer who's fiddling around with
automating Excel, in particular after being able to have the user fill out a form and
it then generate the workbook. I can't quite figure out how to get it to
Merge cells together - I've found how to do it (I think) but can't nut out the syntax. Any help with this would be much appreciated (I've tried looking
for online tutorials, but the ones I've found never touch merging).
Cheers, Damian A.
Just tried it out - Works a wonder. I was close, but I guess thats the
trouble with teaching yourself - Tis a wee bit harder than normal. Thanks!
"kids_pro" wrote: Hi Damian A.
Try this out.
Excel.Applicati on xl = new Excel.Applicati onClass();
Excel.Workbook wb = xl.Workbooks.Ad d(Excel.XlWBATe mplate.xlWBATWo rksheet);
Excel.Worksheet ws = (Excel.Workshee t)wb.ActiveShee t;
ws.Cells[1,1] = "Testing";
Excel.Range range = ws.get_Range(ws .Cells[1,1],ws.Cells[1,2]);
range.Merge(tru e);
range.Interior. ColorIndex =36;
xl.Visible =true;
Cheers,
Kids This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Krmpotic |
last post by:
hi!!
I use the following code to operate excel document:
Excel.Application excelApp = new Excel.ApplicationClass();
//excelApp.Visible = true;
string workbookPath = "c:\\eltina.xls";
Excel.Workbook excelWorkbook =
excelApp.Workbooks.Open("eltina.xls",0,false,5,"","",false,Excel.XlPlatform.
|
by: zxo102 |
last post by:
Hi there,
I need your help for python <--> excel. I want to paste selected
cells (range) to different location on the same sheet in Excel through
python. I have tried it for a while but could not figure it out. Here
is my sample code:
import win32com.client
xl=win32com.client.Dispatch("Excel.Application")
xl.Visible=1
wb =...
|
by: mrid via DotNetMonster.com |
last post by:
hi. im exporting data from a vb form to excel. i am able to create a new
excel file, save and edit it without any trouble, but the formatting is
giving me hell! i need to be able to show certain cells in bold, with
underlining etc. i dont understand how, but in the following code, the
instruction for bold gets picked up for all the cells (even...
|
by: mgoold2002 |
last post by:
I'm moving some code from Excel vbs into a .NET context and I'm very
new to .NET. I'm trying to make this Excel vb code work in .NET. My
questions are: how do I reference cells correctly using the common
"cells(x,y)" reference, where x and y are integer variables. Also, how
do I verify that the cells are empty, since, according to the...
|
by: adamrace |
last post by:
Hi,
I've got two excel files, one has a list of products and their current prices and they all have a product ID, I have another file with a list of price's that need updating. I was wondering what the best way of going about merging the two files together, with the old price and the new price using the ID's. The second file has a list of all...
| |
by: bazdaa |
last post by:
Access 2K3 Append/Update ignore non null cells!
Hi,
I have been tasked with completing an audit of approximately 10,000 items, to which I have generated a list of 40 questions (fields) for each record. I began collating the information in Excel, but found myself getting lost and even experienced major data loss on at least 2 occasions. I...
|
by: Albert-jan Roskam |
last post by:
Hi,
I wrote the program below to merge all xls files in a given directory into one multisheet xls file. It uses xlwt and xlrd. The xls files I use for input are generated by Spss. When I open and re-save the files in Excel, the program works, but when I use the xls files as they were created by Spss, the program returns an error message (see...
|
by: Albert-jan Roskam |
last post by:
Hi John,
Thanks! Using a higher xlrd version did the trick! Regarding your other remarks:
-yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only single-sheet xls files, but I agree it's nicer if the programs works in other cases too.
-and no, I don't intend to use data fields. Wouldn't it be easier...
|
by: BBMcL |
last post by:
Advanced thanks for any helping. I'm running Python on a Mac OS X.
Here's the basic situation. A single group of people had various health measurements performed on them over the course of a few decades. But individuals dropped out of the study between examinations. For instance, for the first exam there were 3,000 individuals, then for the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |