Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Strange error in VBA

I have a line in my code that adjusts the page so that there is no vertical
page break

ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

This line works fine if you F8 through the code, but if you run the macro,
it returns an error (err.number = 1004, Application-defined or object defined
error)

Any help appreciated!

Daniel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Strange error in VBA

Just guessing since I can't see the full code, but if page breaks are not
displayed it gives that error message. Also, if the print area is user
defined it will apply VPageBreak to all pages not just one, so it might balk
at the VPageBreaks(1).

"Daniel Bonallack" wrote:

I have a line in my code that adjusts the page so that there is no vertical
page break

ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

This line works fine if you F8 through the code, but if you run the macro,
it returns an error (err.number = 1004, Application-defined or object defined
error)

Any help appreciated!

Daniel

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Strange error in VBA

Thanks for your help - I'll play around with your suggestions and see if I
can work it out.
A couple of further notes:
- screenupdating is off
- I'm in page break preview
- I can see the page breaks, and the print area is user defined.



"JLGWhiz" wrote:

Just guessing since I can't see the full code, but if page breaks are not
displayed it gives that error message. Also, if the print area is user
defined it will apply VPageBreak to all pages not just one, so it might balk
at the VPageBreaks(1).

"Daniel Bonallack" wrote:

I have a line in my code that adjusts the page so that there is no vertical
page break

ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

This line works fine if you F8 through the code, but if you run the macro,
it returns an error (err.number = 1004, Application-defined or object defined
error)

Any help appreciated!

Daniel

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Strange error in VBA

Hi Daniel,

I've had a look at this and the only time I seem to get the error is when
the view is Normal. In Page Break Preview the code works whether stepping
through the code using F8 or running it through a macro. Try something like
this to force the Page Break Preview view:

Sub PBreakSub()
Dim intWinView As Integer
intWinView = ActiveWindow.View
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, _
regionindex:=1
ActiveWindow.View = intWinView
End Sub

I have done this with screen updating on and off and it works.

If you are still having troubles with this then please give more code so
that we can duplicate your process more accurately.

I hope this helps.

Sean.



"Daniel Bonallack" wrote:

I have a line in my code that adjusts the page so that there is no vertical
page break

ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

This line works fine if you F8 through the code, but if you run the macro,
it returns an error (err.number = 1004, Application-defined or object defined
error)

Any help appreciated!

Daniel

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Strange error in VBA

Thanks! That worked!

"SeanC UK" wrote:

Hi Daniel,

I've had a look at this and the only time I seem to get the error is when
the view is Normal. In Page Break Preview the code works whether stepping
through the code using F8 or running it through a macro. Try something like
this to force the Page Break Preview view:

Sub PBreakSub()
Dim intWinView As Integer
intWinView = ActiveWindow.View
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, _
regionindex:=1
ActiveWindow.View = intWinView
End Sub

I have done this with screen updating on and off and it works.

If you are still having troubles with this then please give more code so
that we can duplicate your process more accurately.

I hope this helps.

Sean.



"Daniel Bonallack" wrote:

I have a line in my code that adjusts the page so that there is no vertical
page break

ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

This line works fine if you F8 through the code, but if you run the macro,
it returns an error (err.number = 1004, Application-defined or object defined
error)

Any help appreciated!

Daniel

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
strange error martinbarnes Excel Discussion (Misc queries) 3 April 1st 08 09:02 PM
strange error AD108 Excel Worksheet Functions 7 August 9th 06 09:22 AM
Strange error Andy Setting up and Configuration of Excel 1 April 18th 06 08:11 PM
Very strange error superkopite Excel Discussion (Misc queries) 3 February 19th 06 11:21 AM
Strange error Filips Benoit Excel Programming 7 October 20th 04 08:02 PM


All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"