×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Run-time error 5941 only in the Word templates

Run-time error 5941 only in the Word templates

Run-time error 5941 only in the Word templates

(OP)
Hello
I have been trying to get this Macro to work but I have had no luck.
It works fine, but when I put my word file with the macro in "My templates" it shows me an error:
Run-time error 5941
The request member of the collection does not exist.

The error occurs in this line:
For Each Zelle In ActiveDocument.Tables(1).Rows(cboAOrt.ListIndex + 2).Cells


Dim Zelle As Cell
Dim Bereich As Range

  I = 0
  If cboAOrt.ListIndex = -1 Then cboAOrt.ListIndex = 0
  For Each Zelle In ActiveDocument.Tables(1).Rows(cboAOrt.ListIndex + 2).Cells
    Set Bereich = ActiveDocument.Range(Start:=Zelle.Range.Start, End:=Zelle.Range.End - 1)
    Select Case I
    Case 0
      Nr = 1
      Zweigstelle = Bereich.Text
    Case 1
      Strasse = Bereich.Text
    Case 2
      Ort = Bereich.Text
    Case 3
      Telefon = Bereich.Text
    Case 4
      Telefax = Bereich.Text
    Case 5
      Mail = Bereich.Text
    Case 6
      Name = Bereich.Text
    Case 7
      Titel = Bereich.Text
    End Select
    I = I + 1
  Next Zelle
  ActiveDocument.Close




Has anybody any ideas why?

Thanks for any help
 

RE: Run-time error 5941 only in the Word templates

(OP)
Thank you for your reply.
Solved!
If someone has the same problem...

http://support.microsoft.com/kb/813983
It seems that the macro could not start properly when I opened the file with the macro from "My templates". The 2nd docx file with the data could not be loaded.
So I opened the docx file with the data, whit a 2nd macro and it works.

CODE

Dim path As String
    
    Application.ScreenUpdating = True
    
    path = Options.DefaultFilePath(wdWorkgroupTemplatesPath)
    path = "C:\..........................."
    Documents.Open FileName:=path + "\data.docx", ReadOnly:=False
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close