Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
maviso5 maviso5 is offline
external usenet poster
 
Posts: 1
Default VB runtime error 5941 Help

Hello

I have created a macro that puts my name and the date in the header when i
push the assigned keys Ctrl + D. However when i run the macro this is what
the VB error takes me to:

'
' Macro2 Macro
'
'
If ActiveWindow.View.SplitSpecial wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True

Selection.TypeText Text:="Daniel Davey 13NB" & vbTab & vbTab
Selection.InsertDateTime DateTimeFormat:="dd/MM/yyyy",
InsertAsField:=True _
, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub


This bit...

ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True


Is the bit that it doesnt like....can anyone help me?


Dan

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default VB runtime error 5941 Help

Is that piece of code on two lines or three? It appears three in your post,
but the first line does not have a visual basic line feed character at the
end of it.

However, you can do the whole thing with just

Selection.Sections(1).Headers(wdHeaderFooterPrimar y).Range _
.Text = "Daniel Davey 13NB" & vbTab & vbTab & _
Format(Date, "dd/MM/yyyy")


--
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

"maviso5" wrote in message
...
Hello

I have created a macro that puts my name and the date in the header when i
push the assigned keys Ctrl + D. However when i run the macro this is what
the VB error takes me to:

'
' Macro2 Macro
'
'
If ActiveWindow.View.SplitSpecial wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True

Selection.TypeText Text:="Daniel Davey 13NB" & vbTab & vbTab
Selection.InsertDateTime DateTimeFormat:="dd/MM/yyyy",
InsertAsField:=True _
, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub


This bit...

ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True


Is the bit that it doesnt like....can anyone help me?


Dan



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default VB runtime error 5941 Help

Do you really need a macro? Why not just use an AutoText entry? It can
include a DATE or CREATEDATE field along with your name. You can assign it
to Ctrl+D if you like.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"maviso5" wrote in message
...
Hello

I have created a macro that puts my name and the date in the header when i
push the assigned keys Ctrl + D. However when i run the macro this is what
the VB error takes me to:

'
' Macro2 Macro
'
'
If ActiveWindow.View.SplitSpecial wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True

Selection.TypeText Text:="Daniel Davey 13NB" & vbTab & vbTab
Selection.InsertDateTime DateTimeFormat:="dd/MM/yyyy",
InsertAsField:=True _
, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub


This bit...

ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True


Is the bit that it doesnt like....can anyone help me?


Dan





  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Beth Melton Beth Melton is offline
external usenet poster
 
Posts: 1,380
Default VB runtime error 5941 Help

You can create a Building Block for this purpose and add it to the Header
gallery instead of using a macro to insert a Building Block and add
additional text.

All you need to do is create your header, select it, on the contextual
Header & Footer tools design tab, click Header, and then click "Save
selection to Header gallery". To make sure it displays at the top of the
gallery, in the Create New Building Block dialog box, create a new category
that starts with a space or symbol. Then to insert your header, on the
Insert tab click Header and then click your Building Block.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP
https://mvp.support.microsoft.com/profile/Melton
What is a Microsoft MVP? http://mvp.support.microsoft.com/gp/mvpfaqs

Guides for the Office 2007 Interface:
http://office.microsoft.com/en-us/tr...295841033.aspx

"maviso5" wrote in message
...
Hello

I have created a macro that puts my name and the date in the header when i
push the assigned keys Ctrl + D. However when i run the macro this is what
the VB error takes me to:

'
' Macro2 Macro
'
'
If ActiveWindow.View.SplitSpecial wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True

Selection.TypeText Text:="Daniel Davey 13NB" & vbTab & vbTab
Selection.InsertDateTime DateTimeFormat:="dd/MM/yyyy",
InsertAsField:=True _
, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub


This bit...

ActiveDocument.AttachedTemplate.BuildingBlockEntri es("
Blank").Insert _
Whe=Selection.Range, RichText:=True


Is the bit that it doesnt like....can anyone help me?


Dan



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with a euntime 5941 error tweacle Microsoft Word Help 1 February 28th 07 08:50 PM
Microsoft Visual C++ Runtime Library Runtime Error! Steve Young Microsoft Word Help 2 April 6th 06 06:01 PM
Word 2003 - when closing receive 'Runtime Error 91' error messages RLC Web Microsoft Word Help 1 January 11th 06 06:16 AM
Error 5941 - The requested member of the collection does not exsis Melisa Microsoft Word Help 3 July 13th 05 03:56 PM
Macro Run-time Error '5941' raymond New Users 4 June 25th 05 12:02 AM


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

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"