Click here to Skip to main content
16,008,942 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerIncompatible file formats Pin
David Mujica5-Mar-10 3:13
David Mujica5-Mar-10 3:13 
AnswerRe: Will an Excel 2007 application work in Excel 2003 Pin
Dave Kreskowiak5-Mar-10 3:15
mveDave Kreskowiak5-Mar-10 3:15 
QuestionDynamicaly make a pop up menu item visible. Pin
karthickmani634-Mar-10 18:33
karthickmani634-Mar-10 18:33 
AnswerRe: Dynamicaly make a pop up menu item visible. Pin
Wayne Gaylard4-Mar-10 19:35
professionalWayne Gaylard4-Mar-10 19:35 
GeneralRe: Dynamicaly make a pop up menu item visible. Pin
karthickmani634-Mar-10 22:50
karthickmani634-Mar-10 22:50 
GeneralRe: Dynamicaly make a pop up menu item visible. Pin
Wayne Gaylard4-Mar-10 23:35
professionalWayne Gaylard4-Mar-10 23:35 
GeneralRe: Dynamicaly make a pop up menu item visible. Pin
Gregory Gadow5-Mar-10 4:11
Gregory Gadow5-Mar-10 4:11 
QuestionChange workbook for read/ write Pin
stephan06074-Mar-10 8:32
stephan06074-Mar-10 8:32 
Hello,

I need your help.
I would like to handle two Excel books with VB.net.

Here is a part of my code:

Dim ExcelApp As Object
Dim ExcelBook As Object
Dim ExcelSheet As Object

ExcelApp = New Excel.Application
ExcelApp.Visible = True

ExcelBook = ExcelApp.Workbooks.Open(Folder & "List2")
ExcelBook = ExcelApp.Workbooks.Open(Folder & "List1")


ExcelApp.Workbooks("List1.xlsx").Activate

'Add data to cells of the first workbook
ExcelSheet = ExcelBook.Worksheets(1)
ExcelSheet.Range("A1").Value = "Book 1"
ExcelSheet.Range("B1").Value = "First Name"
ExcelSheet.Range("A1:B1").Font.Bold = True
ExcelSheet.Range("A2").Value = "Max"
ExcelSheet.Range("B2").Value = "Paul"

ExcelApp.Workbooks("List2.xlsx").Activate ' doe not work


'Add data to cells of the second workbook
ExcelSheet = ExcelBook.Worksheets(1)
ExcelSheet.Range("A1").Value = "Book 2"
ExcelSheet.Range("B1").Value = "First Name"
ExcelSheet.Range("A1:B1").Font.Bold = True
ExcelSheet.Range("A2").Value = "Egon"
ExcelSheet.Range("B2").Value = "Franz"

How can I set "List2.xlsx" active to read and write in List2.xlsx and switch back to "List1.xlsx"
The code to activate List2 does not work.


Thanks in advance

Stephan
AnswerRe: Change workbook for read/ write Pin
Dave Kreskowiak4-Mar-10 9:03
mveDave Kreskowiak4-Mar-10 9:03 
GeneralRe: Change workbook for read/ write Pin
stephan06074-Mar-10 9:29
stephan06074-Mar-10 9:29 
GeneralRe: Change workbook for read/ write Pin
Dave Kreskowiak4-Mar-10 11:06
mveDave Kreskowiak4-Mar-10 11:06 
QuestionBackground color of message box Pin
Tufail Ahmad4-Mar-10 2:47
Tufail Ahmad4-Mar-10 2:47 
AnswerRe: Background color of message box Pin
Dave Kreskowiak4-Mar-10 3:44
mveDave Kreskowiak4-Mar-10 3:44 
GeneralRe: Background color of message box Pin
Tufail Ahmad4-Mar-10 18:05
Tufail Ahmad4-Mar-10 18:05 
GeneralRe: Background color of message box Pin
Anubhava Dimri4-Mar-10 18:19
Anubhava Dimri4-Mar-10 18:19 
GeneralRe: Background color of message box Pin
Dave Kreskowiak5-Mar-10 2:02
mveDave Kreskowiak5-Mar-10 2:02 
QuestionOffice Interop Exception in VB.NET1.1, Please help Pin
Puneet Bhatnagar4-Mar-10 1:53
Puneet Bhatnagar4-Mar-10 1:53 
QuestionGDI+ help Pin
nyt19723-Mar-10 23:43
professionalnyt19723-Mar-10 23:43 
AnswerRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 0:50
professionalWayne Gaylard4-Mar-10 0:50 
AnswerRe: GDI+ help Pin
Dave Kreskowiak4-Mar-10 1:53
mveDave Kreskowiak4-Mar-10 1:53 
GeneralRe: GDI+ help Pin
nyt19724-Mar-10 19:24
professionalnyt19724-Mar-10 19:24 
GeneralRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 21:31
professionalWayne Gaylard4-Mar-10 21:31 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 0:01
professionalnyt19725-Mar-10 0:01 
GeneralRe: GDI+ help Pin
Wayne Gaylard5-Mar-10 0:57
professionalWayne Gaylard5-Mar-10 0:57 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 1:13
professionalnyt19725-Mar-10 1:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.