OdiN
12-19-2007, 04:52 PM
I am having a strange problem with a macro.
The macro is a batch print macro which takes all files in a particular folder and prints them all out. The macro works fine on my computer, and others, but one user is having problems with hers. The only difference is that it's a laptop, but it's got the same version of Office so I don't think that would make any difference.
The error is:
Run-time error 5981
Could not open macro storage
I have done some googling and the suggestions I have found - reinstalling Office and checking for broken references has not worked.
I am posting the code below - maybe there is a problem with it? The bolded line is where the error occurs. Any ideas?
Sub BatchPrint()
Dim fs, f, fc, f1
Dim Cnt As Integer
Dim varExt As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("S:\Batch Print")
Set fc = f.Files
Cnt = 0
Dim myDoc As Word.Document
For Each f1 In fc
varExt = LCase(Right(f1.Name, 4))
If varExt = LCase(".doc") Then
Application.Documents.Open FileName:=f & "\" & f1.Name, Visible:=False
Set myDoc = Application.Documents(f & "\" & f1.Name)
myDoc.PrintOut
myDoc.Close savechanges:=False
Set myDoc = Nothing
varExt = ""
End If
Cnt = Cnt + 1
Next
MsgBox "Batch Print has processed " & Cnt & " files successfully.", vbOKOnly, "Batch Printing Completed"
End Sub
The macro is a batch print macro which takes all files in a particular folder and prints them all out. The macro works fine on my computer, and others, but one user is having problems with hers. The only difference is that it's a laptop, but it's got the same version of Office so I don't think that would make any difference.
The error is:
Run-time error 5981
Could not open macro storage
I have done some googling and the suggestions I have found - reinstalling Office and checking for broken references has not worked.
I am posting the code below - maybe there is a problem with it? The bolded line is where the error occurs. Any ideas?
Sub BatchPrint()
Dim fs, f, fc, f1
Dim Cnt As Integer
Dim varExt As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("S:\Batch Print")
Set fc = f.Files
Cnt = 0
Dim myDoc As Word.Document
For Each f1 In fc
varExt = LCase(Right(f1.Name, 4))
If varExt = LCase(".doc") Then
Application.Documents.Open FileName:=f & "\" & f1.Name, Visible:=False
Set myDoc = Application.Documents(f & "\" & f1.Name)
myDoc.PrintOut
myDoc.Close savechanges:=False
Set myDoc = Nothing
varExt = ""
End If
Cnt = Cnt + 1
Next
MsgBox "Batch Print has processed " & Cnt & " files successfully.", vbOKOnly, "Batch Printing Completed"
End Sub