By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Excel modify in VB6

P: 89
Hi all, I have some code to open an Excel file and I can edit the Excel file easily,

Expand|Select|Wrap|Line Numbers
  1. Dim xlapp As excel.Application
  2. Dim xlbook As excel.WorkBook
  3. Dim xlsheet As excel.WorkSheet
  4.  
  5. Set xlbook = GetObject("d:\TEST.xls")
  6. Set xlapp = xlbook.Parent
  7.  
  8.  
  9. xlapp.Visible = True
  10. xlapp.Windows("TEST.XLS").Visible = True
  11. Set xlsheet = xlbook.Sheets("Sheet1")
  12. xlsheet.Cells(1,1) = "TEXT"
I have some problem with particular case, such as : How i can make Bold of text in the excel sheet, how it is possible to make a table or line,
and change color of text in excel sheet? Thanks a lot 4 your time.
Jan 10 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 634
Hi all, I have some code to open an Excel file and I can edit the Excel file easily,

Expand|Select|Wrap|Line Numbers
  1. Dim xlapp As excel.Application
  2. Dim xlbook As excel.WorkBook
  3. Dim xlsheet As excel.WorkSheet
  4.  
  5. Set xlbook = GetObject("d:\TEST.xls")
  6. Set xlapp = xlbook.Parent
  7.  
  8.  
  9. xlapp.Visible = True
  10. xlapp.Windows("TEST.XLS").Visible = True
  11. Set xlsheet = xlbook.Sheets("Sheet1")
  12. xlsheet.Cells(1,1) = "TEXT"
I have some problem with particular case, such as : How i can make Bold of text in the excel sheet, how it is possible to make a table or line,
and change color of text in excel sheet? Thanks a lot 4 your time.
Hi

You need something like this

xlsheet.Cells(1,1) .Font.ColorIndex = 5 'Blue
xlsheet.Cells(1,1) .Font.Bold = True

Hint; The easiest way to find out Excel syntax is to record macros and adapt the resulting code.


MTB
Jan 14 '08 #2

P: 10
Dim xlapp As Excel.Application
Dim xlbook As Excel.WorkBook
Dim xlsheet As Excel.WorkSheet
Set xlbook = GetObject("d:\visual basic\TEST.xls")
Set xlapp = xlbook.Parent
xlapp.Visible = True
xlapp.Windows("TEST.XLS").Visible = True
Set xlsheet = xlbook.Sheets("Sheet1")
xlsheet.Cells(1, 1) = "TEXT"
xlsheet.Cells(1, 1).Font.Bold = True ' Make text bold
xlsheet.Cells(1, 1).Font.ColorIndex = 8 ' Color
xlsheet.Shapes.AddLine(236.25, 217.5, 351#, 291#).Select ' Line




Hope this code will help you.
Jan 15 '08 #3

Post your reply

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