SaveAs method - am I doing something wrong?

C

Colleyville Alan

I had written an app that queried company names and related info from
Access, opened PowerPoint, created a blank presentation, then copied
individual slides from other PPT files based on a lookup table. At the end
of this app, I used the SaveAs command to rename the new presentation to the
name of the company whose info I was working with.

Now I am trying to do something similar in Excel. I have had memory
corruption problems and "ghost" Excel references. These, I have discovered,
are often caused by references that are not fully qualified and from using
"With" constructs that also may leave a reference not fully qualifited. I
eliminated those and still had memory problems.

So I commented out nearly all of the code and simply had Access perform a
query, load the results into an array, open Excel but not write anything to
Excel. This all worked without a hitch. Then I uncommented out the SaveAs
command and have run into problems. I have established oXLWKS as an object
variable set to the ActiveSheet. I invoke the command " oXLWKS.SaveAs
DestinationPath + strPlanName & ".XLS" which I think should work. I have
also tried this with an object variable set to the ActiveWorkbook rather
than the ActiveSheet. I still get an error that the "SaveAs" method failed.

I only get this error if either there exists a file with the same name (I
chose SaveAs to overwrite it), or if the memory has already been corrupted
(manually closing Excel will not work, I need to use Task Mgr). Is there a
trick to use to overwrite an existing file that I have overlooked? Does the
problem lie elsewhere?

Thanks
 
C

Colleyville Alan

p.s I should have mentioned that I set oXLS.DisplayAlerts = False before the
SaveAs method and oXLS.DisplayAlerts = True following the method.
 
H

Homer

-----8<-------
I invoke the command " oXLWKS.SaveAs
DestinationPath + strPlanName & ".XLS" which I think should work
-----8<-------

If this code was copied from your module, the '+' sign should be a '&'.
 
C

Colleyville Alan

Homer said:
-----8<-------
I invoke the command " oXLWKS.SaveAs
DestinationPath + strPlanName & ".XLS" which I think should work
-----8<-------

If this code was copied from your module, the '+' sign should be a '&'.

I decided to check to see if the file exists and erase it if it does prior
to saving it. Now everything works with no problems.

I will change the plus sign to an ampersand for consistency sake (the plus
sign worked just fine).
Thanks for the reply.
 

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