Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Tables / October 2005

Tip: Looking for answers? Try searching our database.

Error setting AllowBreakAcrossPage

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JWS315 - 27 Oct 2005 17:38 GMT
I get an error trying to set Row 1 of a 2 row table to keep from breaking
across columns - Not sure what is not correct witht code below?  Error is 438
Object does not support this property or method...

Set myRange = wdApp.Selection.Range
Set myTable = wdApp.ActiveDocument.Tables.Add(myRange, 2, 1,
wdWord9TableBehavior, wdAutoFitWindow)
wdApp.ActiveDocument.Tables(wdApp.ActiveDocument.Tables.Count).Rows(1).AllowBreakAcrossPage = False

Jerry
Doug Robbins - Word MVP - 27 Oct 2005 21:20 GMT
I would think that this line

wdApp.ActiveDocument.Tables(wdApp.ActiveDocument.Tables.Count).Rows

should be

wdApp.ActiveDocument.Tables.Count.Rows etc.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I get an error trying to set Row 1 of a 2 row table to keep from breaking
> across columns - Not sure what is not correct witht code below?  Error is
[quoted text clipped - 8 lines]
>
> Jerry
JWS315 - 28 Oct 2005 14:39 GMT
Doug,

I tried your suggestion, however I still receive the same error.  In looking
at Word VBA help it states that the AllowBreakAcrossPage property applies to
a TableStyle object, if this is the case then I would guess that I have the
wrong statement.  

Any suggestions on how the code would look would be appreciated, I have
tried several interations but with no luck.

Thanks
Jerry

> I would think that this line
>
[quoted text clipped - 16 lines]
> >
> > Jerry
Doug Robbins - Word MVP - 28 Oct 2005 18:37 GMT
Turns out you cannot use the .Count property as I suggested.  The following
should work however

Dim i As Long
i = wdApp.ActiveDocument.Tables.Count
wdApp.ActiveDocument.Tables(i).Rows(1).AllowBreakAcrossPages = False

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Doug,
>
[quoted text clipped - 34 lines]
>> >
>> > Jerry
JWS315 - 28 Oct 2005 20:39 GMT
Doug,

The first format of the code I was using is basically the same (I just
replaced i with the assignment) - i still get the same error - Is this
something that cannot be done on a table object?  I found in the help that
AllowBreakAcrossPages applies to a Tablestyle object so maybe I am taking the
wrong approach?

Thanks
Jerry

> Turns out you cannot use the .Count property as I suggested.  The following
> should work however
[quoted text clipped - 41 lines]
> >> >
> >> > Jerry
Doug Robbins - Word MVP - 28 Oct 2005 21:33 GMT
Running a macro with the following code from Word itself, certainly sets
that attribute for the first row in the last table in the active document:

Dim i As Long
i = ActiveDocument.Tables.Count
ActiveDocument.Tables(i).Rows(1).AllowBreakAcrossPages = False

From where are you running this code?  Is the table being added to the
document in the first place?

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Doug,
>
[quoted text clipped - 56 lines]
>> >> >
>> >> > Jerry
JWS315 - 29 Oct 2005 01:25 GMT
I am running the code from an Access module, the first thing I do is add the
table then I try to set the property. I am able to do other things to the
table via Access however run into a problem when trying to set this property.
The table is a 2 row, 1 column table, nothing real elaborate.

Thanks for your help - Jerry

> Running a macro with the following code from Word itself, certainly sets
> that attribute for the first row in the last table in the active document:
[quoted text clipped - 66 lines]
> >> >> >
> >> >> > Jerry
Doug Robbins - Word MVP - 29 Oct 2005 08:49 GMT
Can you post the full code from your Access procedure so that I can try the
same thing from Access.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I am running the code from an Access module, the first thing I do is add
>the
[quoted text clipped - 80 lines]
>> >> >> >
>> >> >> > Jerry
JWS315 - 31 Oct 2005 14:32 GMT
Doung - Here is an abbreviated version of the code I am running:

Option Compare Database

Function rptWord()
Dim wdApp As Object
Dim myRange As Object
Dim myTable As Object
Dim strFilter As String
Dim fName As String
Dim message As String
Dim Response As String
Dim docFinal As Object
Dim tmpFinalDoc As String
Dim wdFname As String

'Display Windows File Save As Dialog
Specifyfilename:
strFilter = ""
strFilter = ahtAddFilterItem(strFilter, "Word Documents (*.doc)", "*.doc")
   fName = ahtCommonFileOpenSave(InitialDir:="C:\", _
       Filter:=strFilter, _
       FilterIndex:=3, _
       OpenFile:=False, _
       FullPath:=True, _
       Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_HIDEREADONLY, _
       DialogTitle:="Specify the folder and file name to save the
Document", _
       FileName:="Application.doc")
   
   If fName = "false" Then
   Err.Number = 32755
   GoTo Err_rptWord
   End If
  message = "Document will be saved in the following folder: " & vbCrLf &
MyCurDir
  Response = MsgBox(message, vbOKCancel, "File Location")
  If Response = vbOK Then
  wdFname = fName
  Else
  GoTo Specifyfilename
  End If

' Create new hidden instance of Word.
  Set wdApp = CreateObject("Word.Application")
   wdApp.Visible = True
  Set docFinal = wdApp.Documents.Add
       docFinal.PageSetup.Orientation = wdOrientPortrait
       docFinal.PageSetup.DifferentFirstPageHeaderFooter = False
       docFinal.PageSetup.LeftMargin = wdApp.InchesToPoints(0.5)
       docFinal.PageSetup.RightMargin = wdApp.InchesToPoints(0.5)
       docFinal.PageSetup.TopMargin = wdApp.InchesToPoints(0.5)
       docFinal.PageSetup.BottomMargin = wdApp.InchesToPoints(0.5)
   docFinal.SaveAs FileName:="" & wdFname & "", FileFormat:=wdWordDocument

'Activate the current window
tmpFinalDoc = GetFileName(wdFname)
wdApp.Windows(tmpFinalDoc).Activate
                       Set myRange = wdApp.Selection.Range
                       Set myTable =
wdApp.ActiveDocument.Tables.Add(myRange, 2, 1, wdWord9TableBehavior,
wdAutoFitFixed)
                       myTable.Borders(wdBorderLeft).LineStyle =
wdLineStyleNone
                       myTable.Borders(wdBorderRight).LineStyle =
wdLineStyleNone
                       myTable.Borders(wdBorderTop).LineStyle =
wdLineStyleNone
                       myTable.Borders(wdBorderBottom).LineStyle =
wdLineStyleNone
                       myTable.Borders(wdBorderHorizontal).LineStyle =
wdLineStyleNone
                       myTable.Borders(wdBorderVertical).LineStyle =
wdLineStyleNone
                       myTable.Borders(wdBorderDiagonalDown).LineStyle =
wdLineStyleNone
                       myTable.Borders(wdBorderDiagonalUp).LineStyle =
wdLineStyleNone
                       myTable.Borders.Shadow = False
                       myTable.Rows(1).AllowBreakAcrossPage = False
                       
'wdApp.ActiveDocument.Tables(wdApp.ActiveDocument.Tables.Count).Rows.AllowBreakAcrossPage = False
   docFinal.SaveAs FileName:="" & wdFname & "", FileFormat:=wdWordDocument
   docFinal.Close
   wdApp.Quit wdDoNotSaveChanges
   Set docFinal = Nothing
   Set wdApp = Nothing
Err_rptWord:
End Function

> Can you post the full code from your Access procedure so that I can try the
> same thing from Access.
[quoted text clipped - 83 lines]
> >> >> >> >
> >> >> >> > Jerry
Doug Robbins - Word MVP - 31 Oct 2005 15:18 GMT
I would suggest that you continue to refer to the document as docFinal and
to the table as myTable and not switch to using ActiveDocument

Set myTable = docFinal.Tables.Add(myRange, 2, 1, wdWord9TableBehavior,
wdAutoFitFixed)

Word may be getting confused by your switching.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Doung - Here is an abbreviated version of the code I am running:
>
[quoted text clipped - 186 lines]
>> >> >> >> >
>> >> >> >> > Jerry
JWS315 - 31 Oct 2005 15:42 GMT
Changed as you suggested and used the following:
myTable.Rows(1).AllowBreakAcrossPage = False

Still get a 438 error code on the statement above...

Jerry

> I would suggest that you continue to refer to the document as docFinal and
> to the table as myTable and not switch to using ActiveDocument
[quoted text clipped - 194 lines]
> >> >> >> >> >
> >> >> >> >> > Jerry
Doug Robbins - Word MVP - 31 Oct 2005 18:47 GMT
myTable.Rows(1).AllowBreakAcrossPage = False

should be:

myTable.Rows(1).AllowBreakAcrossPages = False

Sorry I did not spot that before.  But then you did not spot that I was
using:

AllowBreakAcrossPages

instead of

AllowBreakAcrossPage

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Changed as you suggested and used the following:
> myTable.Rows(1).AllowBreakAcrossPage = False
[quoted text clipped - 218 lines]
>> >> >> >> >> >
>> >> >> >> >> > Jerry
JWS315 - 31 Oct 2005 19:15 GMT
Oh what a difference 1 letter makes!!  Thanks for sticking with me on this!  

Jerry

>  myTable.Rows(1).AllowBreakAcrossPage = False
>
[quoted text clipped - 214 lines]
> >> >> >> >> >>
> >> >> >> >> >> wdApp.ActiveDocument.Tables.Count.Rows etc.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.