473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Exporting and formating Excel Spreadsheet from VB6

Hi, I have the following code to export to a new Excel spreadsheet. What I need to do is format the cells. How can I change the font, font size and colour and most importantly the cells background color.
Thanks in advance.

Private Sub Command1_Click()
Dim appxl
Dim Book As Excel.Workbooks
Dim Wsheet As Excel.Worksheet
FileName = "c:\new.xls"
Set appxl = CreateObject("Excel.Application")
Set Book = appxl.Workbooks
Set Wsheet = Book.Add.Worksheets(1)
appxl.Visible = True

Wsheet.Cells(1, 1) = Text1.Text


End Sub
Dec 27 '07 #1
1 1635
9815402440
180 100+
hi
use following code to format cells

Dim cellRange As String
cellRange = ws.Cells(1, 1).Address
cellRange = cellRange & ":" & ws.Cells(intStartRow, intCol + 1).Address
ws.Range(cellRange).Select
With Selection
.Font.Bold = True
End With

similarly you can apply other settings such as color etc. the easiest way is, open microsoft excel. start macro recording then do whatever you want in the sheet. then open the macro in visual basic editor. all the code will be there. you can use this code in your application

regards
manpreet singh dhillon hoshiarpur
Dec 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nick250 | last post by:
I am having trouble figuring out the correct syntax to export to Excel 2000 and having the name of the newly created Excel spreadsheet based on a value from an open form. I am not exporting to...
1
by: Kaos99 | last post by:
Is there anyway of colour coding values in a report for given criteria and then exporting this formating into an Excel spreadsheet. What I have is a table full of details that are being changed...
2
by: deko | last post by:
I use a complied query to export to Excel like this: SELECT * INTO . FROM tblExcelData; But I have a situation where I need to export several tables into the same worksheet. The idea is to...
2
by: Regnab | last post by:
I've got my code working so that it'll count the number of columns in the table and move across (eg Range A-P and then range Q-W). Problem is when I get to the end of the single letters and get...
1
by: setterst | last post by:
I am quite new to VBA and Access, but I am trying to figure out how to export specific values from a table in Access, so I can save it in a given cell in Excel. I have been able to figure out how...
21
by: bobh | last post by:
Hi All, In Access97 I have a table that's greater than 65k records and I'm looking for a VBA way to export the records to Excel. Anyone have vba code to export from access to excel and have the...
2
by: nofear | last post by:
I used to export my reports as snapshot but now I have to export them to Excel When I export my report to a Excel Spreadsheet the report header and footer are not included Only the data gets...
7
by: semijoyful | last post by:
OS: Win XP SP2 Access version: 2003 Excel version: 2003 I am new at this, as I am sure you have gathered from this post title:) I am working on a form where users can input data in Access and...
9
by: QCLee | last post by:
Sir can you help me to transfer my Access Query to MS excel? i have a command button on the form to export the parameter query named "HVACWindwardQuery" to excel spreadsheet and i got the codes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.