alex101fishing
Member
- Joined
- Dec 30, 2011
- Messages
- 18
- Programming Experience
- 3-5
Hello all,
Having a bit of trouble doing what should be a fairly simple thing! I have made a fairly complicated piece of vb.net software that acts as a database (you can generate custom reports, input data, there are user accounts, stuff like that). And I basically want to format an excel spreadsheet so that it freezes the top row (title row) in each sheet.
using the step into function within excel I have found the basics. I have managed to freeze the entire visible windows worth of spreadsheet. But I can't seem to just freeze the top row, rather annoying!
the below code freezes the whole window (amongst other things)
Now its fairly obvious to me that as i have "New_App.activewindow.FreezePanes = True " its going to select the whole window and freeze that
however if I change that line to "New_App.activecell.FreezePanes = True" for example it throws an error. In fact no matter what i change this line to it will only work if I have used the ".activewindow" function.
I admit I only started vb.net programming about 4 months ago, and within that period it has only been an on and off thing. I am currently having a year out of uni (electronic engineering) to earn some money before i head back for the final year.
By the way if its not apparent "new_app" is the variable assigned to the the excel application running, there is also a variable holding the excel book, and one holding the sheet i.e update_sheet shown above. The reason I have gone back to using the "new_app" is that the freeze function working in its current limited way would only do that within the application variable, when i tried the same thing within the sheet or book again it threw errors.
Thanks for looking this over for me, I appreaciate any feedback good or bad. vb.net programming was never part of my degree learning it on the fly so to speak.
cheers guys and girls
Having a bit of trouble doing what should be a fairly simple thing! I have made a fairly complicated piece of vb.net software that acts as a database (you can generate custom reports, input data, there are user accounts, stuff like that). And I basically want to format an excel spreadsheet so that it freezes the top row (title row) in each sheet.
using the step into function within excel I have found the basics. I have managed to freeze the entire visible windows worth of spreadsheet. But I can't seem to just freeze the top row, rather annoying!
the below code freezes the whole window (amongst other things)
VB.NET:
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
frmCustomReports.RPTSystemMsg.Text = Total & [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]" ID Added"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]frmCustomReports.Timer1.Enabled = true
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] update_sheet.Columns([SIZE=2][FONT=Consolas][COLOR=#a31515]"A"[/COLOR]).ColumnWidth = 10[/FONT][/SIZE][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]New_App.Range([SIZE=2][FONT=Consolas][COLOR=#a31515]"A1"[/COLOR]).Select()[/FONT][/SIZE]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]New_App.ActiveCell.Value = [FONT=Consolas][SIZE=2][COLOR=#a31515]"ID No."[/COLOR][/SIZE][/FONT]
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]New_App.activewindow.FreezePanes = [FONT=Consolas][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][/FONT] [/SIZE][/FONT][/SIZE][/FONT]
Now its fairly obvious to me that as i have "New_App.activewindow.FreezePanes = True " its going to select the whole window and freeze that
however if I change that line to "New_App.activecell.FreezePanes = True" for example it throws an error. In fact no matter what i change this line to it will only work if I have used the ".activewindow" function.
I admit I only started vb.net programming about 4 months ago, and within that period it has only been an on and off thing. I am currently having a year out of uni (electronic engineering) to earn some money before i head back for the final year.
By the way if its not apparent "new_app" is the variable assigned to the the excel application running, there is also a variable holding the excel book, and one holding the sheet i.e update_sheet shown above. The reason I have gone back to using the "new_app" is that the freeze function working in its current limited way would only do that within the application variable, when i tried the same thing within the sheet or book again it threw errors.
Thanks for looking this over for me, I appreaciate any feedback good or bad. vb.net programming was never part of my degree learning it on the fly so to speak.
cheers guys and girls