473,789 Members | 2,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page Break in Excel from VB 2005

I'm using VB 2005 and Excel 2007 and cannot figure out how to insert a page
break before line 72. I've tried several ways but always get an exception
error.

Thanks in advance.

Jul 9 '07 #1
10 7787
On Jul 9, 12:24 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
I'm using VB 2005 and Excel 2007 and cannot figure out how to insert a page
break before line 72. I've tried several ways but always get an exception
error.

Thanks in advance.
I would recommend you use the "Record Macro" functionality of Excel
and record a macro of you adding the pagebreak. Then you just have to
modify that classic vb code to Visual Basic .Net and use it in your
application.

Thanks,

Seth Rowe

Jul 9 '07 #2
Seth,

THanks for the reply. That is what I did and I always get an exception at
run time. I googled and seemed to have tried everything and it never seems
to work.

Steve
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ 22g2000hsm.goog legroups.com...
On Jul 9, 12:24 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
>I'm using VB 2005 and Excel 2007 and cannot figure out how to insert a
page
break before line 72. I've tried several ways but always get an exception
error.

Thanks in advance.

I would recommend you use the "Record Macro" functionality of Excel
and record a macro of you adding the pagebreak. Then you just have to
modify that classic vb code to Visual Basic .Net and use it in your
application.

Thanks,

Seth Rowe
Jul 9 '07 #3
On Jul 9, 12:43 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
Seth,

THanks for the reply. That is what I did and I always get an exception at
run time. I googled and seemed to have tried everything and it never seems
to work.

Steve"rowe_news groups" <rowe_em...@yah oo.comwrote in message

news:11******** **************@ 22g2000hsm.goog legroups.com...
On Jul 9, 12:24 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
I'm using VB 2005 and Excel 2007 and cannot figure out how to insert a
page
break before line 72. I've tried several ways but always get an exception
error.
Thanks in advance.
I would recommend you use the "Record Macro" functionality of Excel
and record a macro of you adding the pagebreak. Then you just have to
modify that classic vb code to Visual Basic .Net and use it in your
application.
Thanks,
Seth Rowe
Post your code.

Thanks,

Seth Rowe

Jul 9 '07 #4
'osheet.HPageBr eaks.Add.Range( "A72")
..

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
On Jul 9, 12:43 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
>Seth,

THanks for the reply. That is what I did and I always get an exception at
run time. I googled and seemed to have tried everything and it never
seems
to work.

Steve"rowe_new sgroups" <rowe_em...@yah oo.comwrote in message

news:11******* *************** @22g2000hsm.goo glegroups.com.. .
On Jul 9, 12:24 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
I'm using VB 2005 and Excel 2007 and cannot figure out how to insert a
page
break before line 72. I've tried several ways but always get an
exception
error.
>Thanks in advance.
I would recommend you use the "Record Macro" functionality of Excel
and record a macro of you adding the pagebreak. Then you just have to
modify that classic vb code to Visual Basic .Net and use it in your
application.
Thanks,
Seth Rowe

Post your code.

Thanks,

Seth Rowe
Jul 9 '07 #5
On Jul 9, 1:18 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
'osheet.HPageBr eaks.Add.Range( "A72")
.

"rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message

news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
On Jul 9, 12:43 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
Seth,
THanks for the reply. That is what I did and I always get an exception at
run time. I googled and seemed to have tried everything and it never
seems
to work.
Steve"rowe_news groups" <rowe_em...@yah oo.comwrote in message
>news:11******* *************** @22g2000hsm.goo glegroups.com.. .
On Jul 9, 12:24 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
I'm using VB 2005 and Excel 2007 and cannot figure out how to insert a
page
break before line 72. I've tried several ways but always get an
exception
error.
Thanks in advance.
I would recommend you use the "Record Macro" functionality of Excel
and record a macro of you adding the pagebreak. Then you just have to
modify that classic vb code to Visual Basic .Net and use it in your
application.
Thanks,
Seth Rowe
Post your code.
Thanks,
Seth Rowe
You need to specify the range using the excel application object. The
following works fine (except for a late binding warning for using
HPageBreaks) for me:

Option Strict Off

'// Of course you'll need to reference
'// Microsoft Excel Object Library 12.0 for this to work
Imports Microsoft.Offic e.Interop.Excel

Module Module1

Sub Main()
Dim excel As New Application()
Dim workbook As Workbook = excel.Workbooks .Add()
workbook.Worksh eets(1).HPageBr eaks.Add(excel. Range("A5"))
excel.Visible = True
End Sub

End Module

Hope That Helps!

Thanks,

Seth Rowe

Jul 9 '07 #6
obook.osheet.HP ageBreaks.Add(E xcel.Range
("A72"))

I get the blue line under Excel.Range

Error 1 'Range' is a type in 'Excel' and cannot be used as an expression.

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
On Jul 9, 1:18 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
> 'osheet.HPageBr eaks.Add.Range( "A72")
.

"rowe_newsgrou ps" <rowe_em...@yah oo.comwrote in message

news:11******* *************** @q75g2000hsh.go oglegroups.com. ..
On Jul 9, 12:43 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
Seth,
>THanks for the reply. That is what I did and I always get an exception
at
run time. I googled and seemed to have tried everything and it never
seems
to work.
>Steve"rowe_new sgroups" <rowe_em...@yah oo.comwrote in message
>>news:11****** *************** *@22g2000hsm.go oglegroups.com. ..
On Jul 9, 12:24 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
I'm using VB 2005 and Excel 2007 and cannot figure out how to
insert a
page
break before line 72. I've tried several ways but always get an
exception
error.
>Thanks in advance.
I would recommend you use the "Record Macro" functionality of Excel
and record a macro of you adding the pagebreak. Then you just have
to
modify that classic vb code to Visual Basic .Net and use it in your
application.
Thanks,
Seth Rowe
Post your code.
Thanks,
Seth Rowe

You need to specify the range using the excel application object. The
following works fine (except for a late binding warning for using
HPageBreaks) for me:

Option Strict Off

'// Of course you'll need to reference
'// Microsoft Excel Object Library 12.0 for this to work
Imports Microsoft.Offic e.Interop.Excel

Module Module1

Sub Main()
Dim excel As New Application()
Dim workbook As Workbook = excel.Workbooks .Add()
workbook.Worksh eets(1).HPageBr eaks.Add(excel. Range("A5"))
excel.Visible = True
End Sub

End Module

Hope That Helps!

Thanks,

Seth Rowe
Jul 9 '07 #7
On Jul 9, 6:05 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
obook.osheet.HP ageBreaks.Add(E xcel.Range
("A72"))

I get the blue line under Excel.Range

Error 1 'Range' is a type in 'Excel' and cannot be used as an expression.

"rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message

news:11******** **************@ g4g2000hsf.goog legroups.com...
On Jul 9, 1:18 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
'osheet.HPageBr eaks.Add.Range( "A72")
.
"rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message
>news:11******* *************** @q75g2000hsh.go oglegroups.com. ..
On Jul 9, 12:43 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
Seth,
THanks for the reply. That is what I did and I always get an exception
at
run time. I googled and seemed to have tried everything and it never
seems
to work.
Steve"rowe_news groups" <rowe_em...@yah oo.comwrote in message
>news:11******* *************** @22g2000hsm.goo glegroups.com.. .
On Jul 9, 12:24 pm, "Stephen Plotnick" <the...@attglob al.netwrote:
I'm using VB 2005 and Excel 2007 and cannot figure out how to
insert a
page
break before line 72. I've tried several ways but always get an
exception
error.
Thanks in advance.
I would recommend you use the "Record Macro" functionality of Excel
and record a macro of you adding the pagebreak. Then you just have
to
modify that classic vb code to Visual Basic .Net and use it in your
application.
Thanks,
Seth Rowe
Post your code.
Thanks,
Seth Rowe
You need to specify the range using the excel application object. The
following works fine (except for a late binding warning for using
HPageBreaks) for me:
Option Strict Off
'// Of course you'll need to reference
'// Microsoft Excel Object Library 12.0 for this to work
Imports Microsoft.Offic e.Interop.Excel
Module Module1
Sub Main()
Dim excel As New Application()
Dim workbook As Workbook = excel.Workbooks .Add()
workbook.Worksh eets(1).HPageBr eaks.Add(excel. Range("A5"))
excel.Visible = True
End Sub
End Module
Hope That Helps!
Thanks,
Seth Rowe- Hide quoted text -

- Show quoted text -
You looked at my code wrong - I used the instance "excel" not the type
"Excel." You need to use the instance of Excel.Applicati on that you
use to create the excel workbooks.

Thanks,

Seth Rowe

Jul 10 '07 #8
Okay, I'm working on your code, but you didn't post all of it. I need
to see the rest of Sub Main as well as the function "Generate_Repor t".

Thanks,

Seth Rowe

Jul 10 '07 #9
The generate_rtn is a routie that checks a line counter and based on the
value calls another routine. I have around 40 lines in a text file that is
being created from another program and I build rows in the spreadsheet based
on the lines in the text file.
You'll need to add the line counter back then and pass it as a
parameter to the Generate_Report method. I removed it as I didn't see
the point to it at the time (though I guessed it had something to do
with the Generate_Report method)

Thanks,

Seth Rowe
Jul 10 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1846
by: Prateek | last post by:
Hi All, Can anybody throw some light on this? I have a crystal report that shows data from a table. This works fine.. However, my requirement is to run an ASP.NET page within crystal so that the user can preview and print the output of this page along with regular table data. Is this possible?
0
3946
by: =?Utf-8?B?Tml5YXpp?= | last post by:
Hi all, Does anyone know how to embed the Excel file in VB.NET 2005 Resources? Here is what I am doing at the moment: 1) In my VB.NET 2005 project code I load the excel with it path into string as: ------------------------------------------------------------------------------------------------ Dim fileNameXL As String = "_MYEXCEL_REPORTS.XLS" Dim pathNameXL As String = "\EXCEL_TEMP\"
14
23171
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update the page with the actual results/page content. We have a page that opens another browser/page...
3
3289
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a "Searching..." page then, refreshes and displays the table I want. I have code that grabs data from the page using cURL but when I look at the data it contains the "Searching..." page and not the table that I want. below is the code i have so far....Thanks...
8
1913
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. The data opens up correctly in MS office Excel 2007 but when we use a mahcine with MS Office 2003 we encountered a message, "Cannot read output file" Is this caused by the Cridview or does anyone know what causes this. Thank in advance.
0
1372
by: svgeorge | last post by:
I have web pages for making several 9 type of payments. The data gets loaded on web page from SQL server 2005 database. Then I have Process payment button(ProcPaymBTM_Click) on the web page(Detail View)This is done. on clicking this button(ProcPaymBTM_Click) on (Detail View) all selected (checked) data columns needs displayed on another page (Review Data) In this page i click confirm payment button to insert selected data to the SQL Tables. I...
0
1336
by: =?Utf-8?B?UHJhc2FkIFBhdGls?= | last post by:
Hi, I have developed a report with Page Breaks based on Group. When i export this report to excel it renders the Page Break as different Excel WorkSheet. I want to render the report as a single Excel WorkSheet is the possible? Thanks! Prasad
1
7186
by: =?Utf-8?B?UHJhc2FkIFBhdGls?= | last post by:
Hi, I have developed a report with Page Breaks based on Group in SQL Server Reporting Services 2000. This report works fine in SQL Reporting Services showing Page Breaks for different groups. When i export this report to excel it renders the Page Break as different Excel WorkSheet. I want to render the report as a single Excel WorkSheet is the possible? Thanks!
0
9511
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2906
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.