Correcting an error message

M

macroapa

I have two options created which fulfill the same function just
producing different wording onto the final Word collation.

However, on one of the options, the following error message is
appearing:

'(91) (object variable or with block variable not set)'

Does anybody know what might be causing this error
 
H

Helmut Weber

Hi,

You got to show us your code.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
M

macroapa

The code is as follows:

Sub PrintAndImage()

'batch name = PrintAndImageFrm.TextBox3.Value

'build end batch pages
Documents(PrintAndImageFrm.TextBox3.Value).Activate
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdPageBreak
ChangeFileOpenDirectory _
"J:\Protection-Customer-Service\Technical Support\MacroFiles\"
Selection.InsertFile FileName:= _
"BaseLetterEndBatch.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.HomeKey Unit:=wdStory
Documents(PrintAndImageFrm.TextBox3.Value).Activate
UpdateBatchPage
Documents(PrintAndImageFrm.TextBox3.Value).Activate
'build start batch pages

Selection.HomeKey Unit:=wdStory
Selection.InsertBreak Type:=wdPageBreak
Selection.HomeKey Unit:=wdStory
ChangeFileOpenDirectory _
"J:\Protection-Customer-Service\Technical Support\MacroFiles\"
Selection.InsertFile FileName:= _
"BaseLetterStartBatch.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.HomeKey Unit:=wdStory

UpdateBatchPage

'run print & image option

If PrintAndImageFrm.OptionButton1.Value = True Or
PrintAndImageFrm.OptionButton2.Value = True Then
ChangeFileOpenDirectory _
"J:\Protection-Customer-Service\Technical
Support\MacroFiles\Central Printing\To be Printed\"

Dim myDate As String
myDate = Format(Date, "yyMMdd")
Dim MyTime As String
MyTime = Format(Time, "hhmmss")
Dim myFile As String
myFile = PrintAndImageFrm.TextBox3.Value
Dim newFile As String
newFile = myDate + MyTime + " " + myFile
ActiveDocument.SaveAs FileName:=newFile

WRKITEMIMAGER

End If



The WRKITEMIMAGER is a seperate piece of coding which will automtically
'image the word document' to a seperate systme. I don't belive that
this is related to the problem
 
R

red6000

You said 'I have two options created which fulfill the same function just
producing different wording onto the final Word collation.' Which part of
your code actually does this and which part is highlighted when it debugs?

A bit more info is needed to be able to help you and i'm sure we'll get to
the bottom of it for you.

so when it debugs, which part of the code is highlighted
 
T

thepool

There doesn't appear to be anythng wrong with it at a quick glance, are you
sure all the directory paths are correct and that the folders are there that
it writes to/reads from.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top