Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Error Saving Excel Sheet
Michael Medici 
     
15 months ago
Hi all,

Firstly thanks to everyone for their time and support.  I try not to bother too much :)

I've run into a problem.  The goal is that when the user hits submit on their order I want to create and save an excel sheet with their order and email it out.  Creating the excel sheet is not the problem.  It opens up on my screen, but I always get an error 1004 and saving error on the sheet.

The code I have for saving is:
xlapp.DisplayAlerts = False
    xlBook.SaveAs ExcName
    xlapp.DisplayAlerts = True

ExcName is built as ExcName = CurrentProject.Path & "\" & RecordSource & ".xlsx"


Now this is on a corporate computer that is using OneDrive, I don't know if that has anything to do with it.

Appreicate the help.
Kevin Robertson  @Reply  
          
15 months ago
Try renaming your variable.
RecordSource is a Reserved Word.
Michael Medici OP  @Reply  
     
15 months ago
Tried that and made it as simple as possible:  
     Filepth = CurrentProject.Path & "\test.xlsx"
But still getting the 1004 error.  I am suspecting that the use of corporate OneDrive is causing the problem.  Any thoughts?
Kevin Robertson  @Reply  
          
15 months ago
OneDrive might be syncing files in the background, causing conflicts when you try to save.
Try saving to a local folder outside OneDrive (like C:\Temp\)

Example
    ExcName = "C:\Temp\" & Filepth & ".xlsx"

If it works, OneDrive is the problem. You might need to adjust sync settings or move the default save location.

File Sharing

Which line is highlighted when you click Debug?
Michael Medici OP  @Reply  
     
15 months ago

Michael Medici OP  @Reply  
     
15 months ago
the debug runs fine with no errors, so this does not seem to be a VBA code issue.  Windows error attached.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/9/2026 6:32:31 PM. PLT: 0s