473,425 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

Excel export from template

40
Hello,

I'm trying to create a new Excel document from a template I've created (Export.xls). I'm having trouble getting it to work, sometimes it works, sometimes it gives me a run-time error '70', permission denied. Here's the code I'm using:

Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook
Dim wks As Excel.Worksheet
Dim CurrentDate As String
Dim sWorkBook As String

DoCmd.Hourglass True

CurrentDate = Format(Date, "mm.dd.yyyy")
sWorkBook = "C:\Test\Export " & CurrentDate & ".xls"

Set appExcel = CreateObject("Excel.Application")
Set wbk = appExcel.Workbooks.Add
Set wks = appExcel.Worksheets(1)
wbk.SaveAs (sWorkBook)
FileCopy "C:\Test\Export.xls", sWorkBook


Any ideas?
Aug 28 '07 #1
1 2121
RobinAG
40
I got it to work, I needed to get rid of the wbk.SaveAs statement. I don't know, however, why I was getting the permission denied error.


Hello,

I'm trying to create a new Excel document from a template I've created (Export.xls). I'm having trouble getting it to work, sometimes it works, sometimes it gives me a run-time error '70', permission denied. Here's the code I'm using:

Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook
Dim wks As Excel.Worksheet
Dim CurrentDate As String
Dim sWorkBook As String

DoCmd.Hourglass True

CurrentDate = Format(Date, "mm.dd.yyyy")
sWorkBook = "C:\Test\Export " & CurrentDate & ".xls"

Set appExcel = CreateObject("Excel.Application")
Set wbk = appExcel.Workbooks.Add
Set wks = appExcel.Worksheets(1)
wbk.SaveAs (sWorkBook)
FileCopy "C:\Test\Export.xls", sWorkBook


Any ideas?
Aug 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
6
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel...
8
by: DC Gringo | last post by:
I have a simple button that should open another window and export a datagrid to an Excel file. I'm getting: "Name 'window' is not declared." What do I need to declare or import? <INPUT...
4
by: Prasad Dannani | last post by:
Hi, We have to export our data in sql server table to any excel sheet. We have a template to export, using oledb we are inserting rows to this template and generating the excel output. The...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
4
by: Grey | last post by:
i need to export the data set to excel in asp.net, but my requirement is need to use the template, i.e. some column should be lock as read-only and some column should be highlighted. the format...
5
by: Reggie | last post by:
Hi and TIA! I have an export procedure that exports my data from my datagrids to excel. The problem is that I lose leading zero's cause excel removes them and doesn't treat them as text. Is it...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.