word vba error <automation error>

V

VBALover

Hi All,

Here is the code:

Set objXL = New Excel.Application
Set objwkb = objXL.Workbooks.Open(datafile)

objwkb.Save '<--- Error in this code

If I get this error, I only need to close the Word and re-open again. Then
there will be no error.

The error not happen all the time. It may happens after I copy the excel to
the same directory.


Thanks for advice.


Regards
 
J

Jezebel

Presumably there are more things going on between the Open and Save
instructions. Excel will throw an error on Save if there were any unresolved
errors during processing along the way.

The previous times I've met the problem, in my own and in other people's
code, it was to do with the Range keyword. If you copied some code from
Excel VBA to Word VBA, you might have a Sort instruction along the lines of

With objwkb.sheets(1).rows("3:5)
.Sort Key1:=Range("A6"), Order1:=....
end with

The error is the missing period in front of "Range". Excel doesn't report
this as an error; it just sulks silently and throws a tantrum later on.
 
V

VBALover

oh... "unresolved errors".

Thanks ~~



Jezebel said:
Presumably there are more things going on between the Open and Save
instructions. Excel will throw an error on Save if there were any unresolved
errors during processing along the way.

The previous times I've met the problem, in my own and in other people's
code, it was to do with the Range keyword. If you copied some code from
Excel VBA to Word VBA, you might have a Sort instruction along the lines of

With objwkb.sheets(1).rows("3:5)
.Sort Key1:=Range("A6"), Order1:=....
end with

The error is the missing period in front of "Range". Excel doesn't report
this as an error; it just sulks silently and throws a tantrum later on.
 

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