#1   Report Post  
W
 
Posts: n/a
Default Macro not found

I am having some troubles with macros and am wondering if anyone can help. I
have recorded macros and then when I go to play them it says the file cannot
be found. What I am doing when this happens is that I have been working in a
different folder and not in the folder the macro is in. When I go into the
folder the macro is in and play it, it works fine and I don't get an error
message. How do I set the macros up to look in one specific folder? I have
tried recording the macro and doing the actions (file open, go to the
specific folder, etc) but it still does not seem to work. Can anyone help me
PLEASE??? Thank you!
  #2   Report Post  
garfield-n-odie
 
Posts: n/a
Default

Post your macro code here and someone can probably tell you how
to fix it.

W wrote:

I am having some troubles with macros and am wondering if anyone can help. I
have recorded macros and then when I go to play them it says the file cannot
be found. What I am doing when this happens is that I have been working in a
different folder and not in the folder the macro is in. When I go into the
folder the macro is in and play it, it works fine and I don't get an error
message. How do I set the macros up to look in one specific folder? I have
tried recording the macro and doing the actions (file open, go to the
specific folder, etc) but it still does not seem to work. Can anyone help me
PLEASE??? Thank you!


  #3   Report Post  
Graham Mayor
 
Posts: n/a
Default

Macros are not contained in folders. They are contained in documents or by
default in the normal.dot template.
To change the file open directory (which is what you appear to have
recorded) you need the following command line

ChangeFileOpenDirectory "path"

where path is the full path to the directory in question.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


W wrote:
I am having some troubles with macros and am wondering if anyone can
help. I have recorded macros and then when I go to play them it says
the file cannot be found. What I am doing when this happens is that
I have been working in a different folder and not in the folder the
macro is in. When I go into the folder the macro is in and play it,
it works fine and I don't get an error message. How do I set the
macros up to look in one specific folder? I have tried recording the
macro and doing the actions (file open, go to the specific folder,
etc) but it still does not seem to work. Can anyone help me
PLEASE??? Thank you!



  #4   Report Post  
W
 
Posts: n/a
Default

okay, here's the code for my one macro. I hope this helps you! Thank you!

' Macro recorded 10/13/2005 by WEichorn
' Selection.InsertFile FileName:="Letterhead.dot", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
True, DateLanguage:=wdEnglishCanadian,
CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeParagraph
Selection.TypeParagraph


"garfield-n-odie" wrote:

Post your macro code here and someone can probably tell you how
to fix it.

W wrote:

I am having some troubles with macros and am wondering if anyone can help. I
have recorded macros and then when I go to play them it says the file cannot
be found. What I am doing when this happens is that I have been working in a
different folder and not in the folder the macro is in. When I go into the
folder the macro is in and play it, it works fine and I don't get an error
message. How do I set the macros up to look in one specific folder? I have
tried recording the macro and doing the actions (file open, go to the
specific folder, etc) but it still does not seem to work. Can anyone help me
PLEASE??? Thank you!



  #5   Report Post  
garfield-n-odie
 
Posts: n/a
Default

I'm no macro guru by any stretch of the imagination, but it seems
to me that if you include the foldername with the filename (e.g.,
"C:\foldername\Letterhead.dot"), it should work.

W wrote:

okay, here's the code for my one macro. I hope this helps you! Thank you!

' Macro recorded 10/13/2005 by WEichorn
' Selection.InsertFile FileName:="Letterhead.dot", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
True, DateLanguage:=wdEnglishCanadian,
CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeParagraph
Selection.TypeParagraph


"garfield-n-odie" wrote:


Post your macro code here and someone can probably tell you how
to fix it.

W wrote:


I am having some troubles with macros and am wondering if anyone can help. I
have recorded macros and then when I go to play them it says the file cannot
be found. What I am doing when this happens is that I have been working in a
different folder and not in the folder the macro is in. When I go into the
folder the macro is in and play it, it works fine and I don't get an error
message. How do I set the macros up to look in one specific folder? I have
tried recording the macro and doing the actions (file open, go to the
specific folder, etc) but it still does not seem to work. Can anyone help me
PLEASE??? Thank you!






  #6   Report Post  
Charles Kenyon
 
Posts: n/a
Default

You are right that it does require a full path. I generally use a variable
to hold the workgroup templates path and use that as a starting point for my
path. For instance my letterhead is in the Letters and Faxes folder of the
workgroup path.

However,

(1) I think what you are doing could possibly be done bette using the
template as a template and including the date field in your template.

(2) You want your letterhead set up using headers and footers. This is
easily done in your template, not so easy using a macro.

Take a look at: How to set up letterhead or some other document where you
want one header on the first page and a different header on other pages.
http://www.addbalance.com/word/headersfooters.htm This gives step-by-step
instructions. (It also has the following links)

Some other pages to look at:

Letterhead Tips and Instructions
http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm

Letterhead Textboxes and Styles tutorial
http://addbalance.com/word/download....StylesTutorial

Template Basics
http://www.addbalance.com/usersguide/templates.htm

How to Create a Template - Part 2 - essential reading
http://www.mvps.org/word/FAQs/Custom...platePart2.htm

Word "Forms"
http://www.addbalance.com/word/wordw...rces.htm#Forms and

Word for Word Perfect Users
http://www.addbalance.com/word/wordperfect.htm if you are coming from a WP
environment (or even if you are not).

I pull updated material from my letterhead template in subsidiary
letterheads. Some of the code for this is below. It isn't perfect but it
shows how I construct the path dynamically rather than hard-coding it.

Sub AutoNew()
' First part operates only in template other than "Kenyon Legal
Letter.dot"
' Brings in Headers and styles from "Kenyon Legal Letter.dot"
' Revised 28 January 2004
'
' Designed to allow changes in main letterhead headers or styles to
' automatically propogate in forms created by using SaveAs
' from that template.
'
' The name of the Base Template ("Kenyon Legal Letter.dot") is stored
' as a document variable in that template. That variable's
' name is "BaseName." Templates created using the base template
' will also have the same variable.
'
' If the name of the base template is changed, you need to change
' the variable in not only the base template but in
' every template that is based on it or this procedure
' will generate an error.
'
Dim sTemplateName As String
sTemplateName = ActiveDocument.Variables("BaseName").Value
' If this is not the base template for the letterhead, attach base
template
If ActiveDocument.AttachedTemplate.Name sTemplateName Then
ReplaceHeaders (sTemplateName) ' calls private sub (below)
' Application.OrganizerCopy( ' (for future work to update letterhead
styles)
AttachBase (sTemplateName)
End If
' Second part
' All new letters - show UserForm
Dim myForm As frmAddress
Set myForm = New frmAddress
myForm.Show
Unload myForm
Set myForm = Nothing
End Sub
Function WorkGroupPath() As String
' Written by Charles Kenyon
' February 28, 2003
'
' Used by templates menus to set location of templates.
' Returns workgroup tempates path with "\" at the end.
'
' This is needed because if the folder is a network drive rather
' than a folder, it will have the "\" already. If it is a folder,
' it will not have the backslash. This function gives a string
' with the backslash in either case.
'
WorkGroupPath =
Application.Options.DefaultFilePath(wdWorkgroupTem platesPath)
If Right(WorkGroupPath, 1) "\" Then
WorkGroupPath = WorkGroupPath & "\"
End If
End Function

Private Sub AttachBase(sTemplateName As String)
' Procedure written by Charles Kyle Kenyon 8 Dec 2003
' Reattaches Base Letterhead Template for form letters - attaches styles
'
Dim sTemplatesPath As String
sTemplatesPath = WorkGroupPath & "Letters & Faxes\"
'
With ActiveDocument
.UpdateStylesOnOpen = True
.AttachedTemplate = sTemplatesPath & sTemplateName
.UpdateStylesOnOpen = False
.AttachedTemplate = sTemplatesPath & sTemplateName
End With
End Sub

Sub SelectIt(iField As Integer)
' Routine goes to beginning of document and then goes to field
' iField sets number of field to go to
' Used in new document menus
'
Dim iNumber As Integer
Selection.HomeKey Unit:=wdStory
For iNumber = 1 To iField
Selection.NextField.Select
Next iNumber
End Sub

Private Sub ReplaceHeaders(sTemplateName As String)
' Altered to delete stories 8 October 2005

' Replaces Header and FirstPageHeader with contents from
' base template
' Replaces Footer and FirstPageFooter with contents from
' base template
' Assumes that bookmarks have been preserved in base and copies.
' Otherwise will generate error
' Required bookmarks are "Footer1," "Footer2," "Header1," and
"Header2"
'
Dim rRange As Range
Dim sFooter As String
Dim sHeader As String
'
' First Page Header
Set rRange = ActiveDocument.StoryRanges(wdFirstPageHeaderStory)
rRange.Delete
rRange.InsertFile FileName:=WorkGroupPath _
& "Letters & Faxes\" & sTemplateName, _
Range:="Header1", _
ConfirmConversions:=False, Attachment:=False, Link:=False
' Continuation Header
Set rRange = ActiveDocument.StoryRanges(wdPrimaryHeaderStory)
rRange.Delete
rRange.Style = ActiveDocument.Styles("Header 3")
rRange.InsertFile FileName:=WorkGroupPath _
& "Letters & Faxes\" & sTemplateName, _
Range:="Header2", _
ConfirmConversions:=False, Attachment:=False, Link:=False
' First Page Footer
Set rRange = ActiveDocument.StoryRanges(wdFirstPageFooterStory)
rRange.Delete
rRange.InsertFile FileName:=WorkGroupPath _
& "Letters & Faxes\" & sTemplateName, _
Range:="Footer1", _
ConfirmConversions:=False, Attachment:=False, Link:=False
' Continuation Footer
Set rRange = ActiveDocument.StoryRanges(wdPrimaryFooterStory)
rRange.Delete
rRange.InsertFile FileName:=WorkGroupPath _
& "Letters & Faxes\" & sTemplateName, _
Range:="Footer2", _
ConfirmConversions:=False, Attachment:=False, Link:=False
End Sub


Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


"garfield-n-odie" wrote in message
...
I'm no macro guru by any stretch of the imagination, but it seems to me
that if you include the foldername with the filename (e.g.,
"C:\foldername\Letterhead.dot"), it should work.

W wrote:

okay, here's the code for my one macro. I hope this helps you! Thank
you!

' Macro recorded 10/13/2005 by WEichorn
' Selection.InsertFile FileName:="Letterhead.dot", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy",
InsertAsField:= _
True, DateLanguage:=wdEnglishCanadian,
CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeParagraph
Selection.TypeParagraph


"garfield-n-odie" wrote:


Post your macro code here and someone can probably tell you how to fix
it.

W wrote:


I am having some troubles with macros and am wondering if anyone can
help. I have recorded macros and then when I go to play them it says
the file cannot be found. What I am doing when this happens is that I
have been working in a different folder and not in the folder the macro
is in. When I go into the folder the macro is in and play it, it works
fine and I don't get an error message. How do I set the macros up to
look in one specific folder? I have tried recording the macro and doing
the actions (file open, go to the specific folder, etc) but it still
does not seem to work. Can anyone help me PLEASE??? Thank you!





  #7   Report Post  
W
 
Posts: n/a
Default

Graham, not sure what I typed but the first time I tried that it didn't work
but now it seems to! Thanks you!!!

"Graham Mayor" wrote:

Macros are not contained in folders. They are contained in documents or by
default in the normal.dot template.
To change the file open directory (which is what you appear to have
recorded) you need the following command line

ChangeFileOpenDirectory "path"

where path is the full path to the directory in question.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


W wrote:
I am having some troubles with macros and am wondering if anyone can
help. I have recorded macros and then when I go to play them it says
the file cannot be found. What I am doing when this happens is that
I have been working in a different folder and not in the folder the
macro is in. When I go into the folder the macro is in and play it,
it works fine and I don't get an error message. How do I set the
macros up to look in one specific folder? I have tried recording the
macro and doing the actions (file open, go to the specific folder,
etc) but it still does not seem to work. Can anyone help me
PLEASE??? Thank you!




  #8   Report Post  
W
 
Posts: n/a
Default

Thank you! now it seems to be working great!!!!

"garfield-n-odie" wrote:

I'm no macro guru by any stretch of the imagination, but it seems
to me that if you include the foldername with the filename (e.g.,
"C:\foldername\Letterhead.dot"), it should work.

W wrote:

okay, here's the code for my one macro. I hope this helps you! Thank you!

' Macro recorded 10/13/2005 by WEichorn
' Selection.InsertFile FileName:="Letterhead.dot", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
True, DateLanguage:=wdEnglishCanadian,
CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeParagraph
Selection.TypeParagraph


"garfield-n-odie" wrote:


Post your macro code here and someone can probably tell you how
to fix it.

W wrote:


I am having some troubles with macros and am wondering if anyone can help. I
have recorded macros and then when I go to play them it says the file cannot
be found. What I am doing when this happens is that I have been working in a
different folder and not in the folder the macro is in. When I go into the
folder the macro is in and play it, it works fine and I don't get an error
message. How do I set the macros up to look in one specific folder? I have
tried recording the macro and doing the actions (file open, go to the
specific folder, etc) but it still does not seem to work. Can anyone help me
PLEASE??? Thank you!




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
Macro Button Won't Stay on Toolbar caleb Microsoft Word Help 2 June 14th 05 11:59 PM
Possible bug when recording a Word Macro Raven95 Microsoft Word Help 4 April 30th 05 09:49 PM
Reference Manager: Macro cannot be found or has been disabled Christy Microsoft Word Help 1 February 20th 05 09:27 AM
Save As is not working due to macro security settings Craig Meritz Microsoft Word Help 1 December 16th 04 03:53 AM
2000 to 2002 macro and "Could not open macro storage" Art Farrell Mailmerge 1 December 6th 04 12:40 PM


All times are GMT +1. The time now is 06:55 PM.

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"