Results 1 to 3 of 3
  1. #1
    murfeezlaw is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    26

    Unhappy The requested member of the collection does not exist.

    Ugghhh i'm dying over here. I have an Access db that opens up an Instance of Word and creates a policy. The first time it goes thru ok but every other time it runs I get the following error "The requested member of the collection does not exist." There is a lot of code but I've commented most of it out to narrow down where I'm getting the error. I'm getting the error at:



    objWord.ActiveDocument.Tables(intTableCount).Rows( 2).SetHeight RowHeight:=objWord.InchesToPoints(1.76), _ HeightRule:=Word.wdRowHeightExactly

    I've also triedobjWord.ActiveDocument.Tables(intTableCount).Rows( 2).SetHeight RowHeight:=objWord.InchesToPoints(1.76), _
    HeightRule:=wdRowHeightExactly but I get the same error.

    Code:
    Option Compare Database
    Option Explicit
    Public objWord As Object
    
    On Error GoTo notloaded1
            Set objWord = GetObject(, "Word.Application")
    notloaded1:
            If Err.Number <> 0 Then
                Set objWord = CreateObject("Word.Application")
            End If
            objWord.Visible = True
            
            objWord.Documents.Add
    objWord.ActiveDocument.Sections.PageSetup.LeftMargin = objWord.InchesToPoints(0.5)
    objWord.ActiveDocument.Sections.PageSetup.RightMargin = objWord.InchesToPoints(0.5)
    objWord.ActiveDocument.Sections.PageSetup.TopMargin = objWord.InchesToPoints(0.5)
    objWord.ActiveDocument.Sections.PageSetup.BottomMargin = objWord.InchesToPoints(0.5)
    
    
    objWord.Selection.Font.Name = "Arial"
        objWord.Selection.Font.Size = 10
                
        objWord.ActiveDocument.Tables.Add Range:=objWord.Selection.Range, NumRows:=5, NumColumns:=1, DefaultTableBehavior:=wdWord8TableBehavior
    
    
        intTableCount = intTableCount + 1
    
    
        With objWord.Selection.ParagraphFormat
            .SpaceBefore = 0
            .SpaceBeforeAuto = False
            .SpaceAfter = 0
            .SpaceAfterAuto = False
            .LineSpacingRule = wdLineSpaceSingle
            .Alignment = wdAlignParagraphLeft
            .WidowControl = True
            .KeepWithNext = False
            .KeepTogether = False
            .PageBreakBefore = False
            .NoLineNumber = False
            .Hyphenation = True
            .OutlineLevel = wdOutlineLevelBodyText
            .CharacterUnitLeftIndent = 0
            .CharacterUnitRightIndent = 0
            .CharacterUnitFirstLineIndent = 0
            .LineUnitBefore = 0
            .LineUnitAfter = 0
            .MirrorIndents = False
            .TextboxTightWrap = wdTightNone
        End With
    
    
    
    
        With objWord.Selection.Tables(1)
            .Columns.PreferredWidth = objWord.InchesToPoints(7.47)
            If .Style <> "Table Grid" Then
                .Style = "Table Grid"
            End If
            .ApplyStyleHeadingRows = True
            .ApplyStyleLastRow = False
            .ApplyStyleFirstColumn = True
            .ApplyStyleLastColumn = False
            .ApplyStyleRowBands = True
            .ApplyStyleColumnBands = False
        End With
    
        objWord.Selection.TypeText Text:="DECLARATIONS"
        objWord.Selection.TypeParagraph
        objWord.Selection.TypeText Text:=strPolicyType
        objWord.Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
        objWord.Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
        objWord.Selection.SelectCell
        objWord.Selection.ParagraphFormat.Alignment = Word.wdAlignParagraphCenter
        objWord.Selection.Cells.VerticalAlignment = Word.wdCellAlignVerticalTop
        objWord.Selection.Font.Bold = wdToggle
        objWord.Selection.MoveDown Unit:=wdLine, Count:=1
        objWord.Selection.Cells.Split NumRows:=1, NumColumns:=3, MergeBeforeSplit:=False
    
    
    
    
        objWord.ActiveDocument.Tables(intTableCount).Rows(2).SetHeight RowHeight:=objWord.InchesToPoints(1.76), _
            HeightRule:=Word.wdRowHeightExactly
    
    
    
        objWord.ActiveDocument.SaveAs FileName:= txtPolNumber & ".doc"
    
        objWord.Quit    
        Set objWord = Nothing

    Any help or ideas would be greatly appreciated! Thank you all!
    Ted

  2. #2
    murfeezlaw is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    26
    Forgot to mention i'm running Access 2007 at work

  3. #3
    murfeezlaw is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    26
    I figured it out. My problem was with the variable intTableCount. I forgot to set it to 0 in the beginning of the code, it was holding the value from the last run so when it incremented it incremented from the last value instead of 0.


    objWord.ActiveDocument.Tables(intTableCount).Rows(2).SetHeight RowHeight:=objWord.InchesToPoints(1.76), _ HeightRule:=Word.wdRowHeightExactly

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 11-16-2012, 10:15 AM
  2. Replies: 4
    Last Post: 09-18-2012, 03:01 PM
  3. VBA Help Requested
    By aamer in forum Access
    Replies: 7
    Last Post: 03-07-2012, 02:14 PM
  4. Requested Password in new database access
    By baldo10 in forum Access
    Replies: 3
    Last Post: 09-07-2010, 04:23 AM
  5. Help requested for calculating age
    By techexpressinc in forum Queries
    Replies: 3
    Last Post: 01-28-2009, 11:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums