Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need help with a euntime 5941 error | Microsoft Word Help | |||
Microsoft Visual C++ Runtime Library Runtime Error! | Microsoft Word Help | |||
Word 2003 - when closing receive 'Runtime Error 91' error messages | Microsoft Word Help | |||
Error 5941 - The requested member of the collection does not exsis | Microsoft Word Help | |||
Macro Run-time Error '5941' | New Users |