I have an Excel Dashboard where i have buttons to perform some data cleansing in MS Access. The Access database fetches data from other two Excel files. When i run the MS Access separately i am not facing any issue. My user wanted all the operations to be done from the final Excel dashboard.So when i call the Access module from the final Excel report, the input excel files opens as read only and Access operations not completed. Every time i wam forced to kill the process in the task manager. i want the Input Excel files to close normally and Access to perform the set of operations and only the final value to be retrieved in the Excel dashboard.
Use this piece of code after uploading the file
'This will set the sheet object to nothing
set xlsht=Nothing
'This closes the workbook
xlwkb.Close
set xlwkb=Nothing
'This closes the excel application
xlapp.Quit
set xlapp=Nothing
Related
I've created a multi-user Access Form that will essentially be open for most of the day on several peoples computers. On this form, I've created a button that will import an excel spreadsheet via VBA. The code is:
Option Compare Database
Private Sub Command0_Click()
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE ExcelTable.* FROM ExcelTable;"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "ExcelTable", "C:\Users\JohnDoe\Documents\MyTable.xlsx", True, "Data!A6:DB" & numberofrows
DoCmd.SetWarnings True
End Sub
This code imports the data fine. However, users will frequently need to update the spreadsheet throughout the day. There are 2 problems that I am frequently running into:
If a user attempts to overwrite the original spreadsheet with an updated version, they receive an error message "Cannot access read-only document".
If the user attempts to open the spreadsheet, they receive the error message that the excel file is locked for editing.
I was under the impression that by running the above VBA code, the user is importing a static table (not a linked table), meaning that once the table is imported into Access, it's no longer referencing the original Excel file.
How do I get around these error messages?
The users will need to update the excel file several times throughout the day and right now, everyone has to completely exit Access in order to access the original excel file.
I have an MS Word document for a mail merge, and I want it to use a particular MS Access form to pull the data from a query. However this locks the file, which is a problem because it's also the file I use. Thus I have to close my file before opening the mail merge.
How do I set the MS Access file to not be locked by anything?
I've a SSIS solution to import data from Excel file to SQl Server table.
But the Excel file have differents tabs and I need to go for each one evaluating the header value for A1 cell, if it's for sample "Appointment Count", that is the tab I have to imported.
some idea how can I do it?
thanks
Eliana
You can create an OLEDB connection manager, using the Microsoft Jet Provider to open the Excel file. From there, you can create a For Each loop container to iterate through the worksheets therein.
For an example of how to implement this, check here.
*Remember that the MS Jet provider is available in 32-bit only.
I have created a package to fetch data from two SQL Server tables, and using merge join combined this data, then stored the result into an Excel destination.
The first time it works fine. The second time it stores repeated data in the Excel file.
How do I overwrite the Excel file rows?
Yes, Possible!
Here is the solution:
First go to your Excel Destination Click to New Button next to Name of Excel Sheet, copy the DML query inside.
Then put an Execute SQL Task into your Control Flow and connect it to your data flow that contains Excel destination. Set the Connection Type To Excel, Set the Connection to your Excel Destination's Excel Connection Manager, go to SQL Statement and type :
Drop TABLE `put the name of the sheet in the excel query you just copied`
Go
finally paste the query after it.
It is all you need to do to solve the problem.
You can refer to this link for a complete info:
http://dwhanalytics.wordpress.com/2011/04/07/ssis-dynamically-generate-excel-tablesheet/
Yes, Possible!
Using SSIS we can solve this problem:
first of all, crate an Excel format file (Structure Format using Excel Connection Manager) at one location as a template file. Then create a copy of that excel file using FILE SYSTEM TASK in another location and make sure that SET OverwriteDestination=True. Finally, using a data flow task, insert data into the new copied file. whenever we want insert data, it will create a copy of the template excel file and then load the data.
Unfortunately the Excel connection manager does not have a setting that allows overwriting the data. You'll need to set up some file manipulation using the File System Task in the Control Flow.
There are several possibilities, here's one of them. You can create a template file (which just contains the sheet with the header) and prior to the Data Flow Transformation a File System Task copies it over the previously exported file.
The File System Task (MSDN)
For Excel it will append data. There is no such option available for overwriting data.
You have to delete and recreate the file through the File System task.
Using a CSV file with flat-file connection manager would serve your purpose of overwriting.
The best solution for me was using File System Tasks to delete and recreate the Excel files from a template.
What I was trying to do was to send every employee a report with Excel attachment in the same format but different data. In a foreach container for each employee, I get the required data, create an Excel file and send a mail with the Excel file attached.
I first:
Create an Excel template (manually)
Create an original Excel file to be used (manually)
Then in the foreach container:
Delete the original file (SSIS File System Task )
Copy the template as the original file (SSIS File System Task)
Get the data from SQL Server and write them to the original file (SSIS Data Flow Task)
Send the mail (SSIS -> SQL Stored Procedure)
I need to store PDF files in an Access database on a shared drive using a form. I figured out how to do this in tables (using the OLE Object field, then just drag-and-drop) but I would like to do this on a Form that has a Save button. Clicking the save button would store the file (not just a link) in the database. Any ideas on how to do this?
EDIT:
I am using Access 2003, and the DB will be stored on a share drive, so I'm not sure linking to the files will solve the problem.
We have several databases that contain 10's of thousands of documents (pdf, doc, jpg, ...), no problem at all. In Access, we use the following code to upload a binary object to a binary field:
Function LoadFileFromDisk(Bestand, Optional FileName As String = "")
Dim imgByte() As Byte
If FileName = "" Then FileName = strFileName
Open FileName For Binary Lock Read As #1
ReDim imgByte(1 To LOF(1))
Get #1, , imgByte
Close #1
If Not IsEmpty(imgByte) Then Bestand.Value = imgByte
End Function
In this case, Bestand is the field that contains the binary data.
We use MS SQL Server as a backend, but the same should work on an Access backend.
If you used the same concept but upsized to SQL Server- storing PDFs inside of an Image datatype (or varbinary(max)) then you could SEARCH INSIDE THE PDFs using Full Text Search.
I show that Microsoft says you can do this for any file type where you can register an IFILTER product.. and I just was at the Adobe website the other day and say that their Acrobat IFILTER is indeed FREE.
Maybe this will help: ACC2000: Reading, Storing, and Writing Binary Large Objects (BLOBs).
What they do: Read a file in chunks and add it to a blob using a VBA function.
A field of OLE Object, by default would use a Bound Object Frame on the form. Right click on it and you can Insert an object. It comes complete with browsing for the file. Double-click on the field and the actual document will open.
I recommend going with David's advice and link. Unless you have a need to transfer a single file and want all the PDF's included. Size and performance will be an issue.
If security is an issue and the Access file is the only control you have (You are unable to set security on the folder containing all the linked files.), then you would have to embed.