MS Access Retrieve and Modify Arguments of Steps in a Macro - vba

I have a MS Access database with a macro. The macro will, obviously, import files, run queries and generating spreadsheet reports on a daily basis.
Now I want to modify the macro to process files within a start/end date range. But the file names used in the TransferText and TransferSpreadsheet actions are all fixed and I need to separate the files into different folders.
Can I change that using VBA?
I have been try looking up in the web but I have difficulty find any resources that explain how to manipulate the actions within a macro.
File copying would be another option but I would take that as the last resort.

Related

Toad Automation load all various excel files from a folder

I have to load all excel files into a table.
now the issue I am getting is that the file name is always going to be different no matter what and the same goes for the sheet. Is it possible to setup the toad automation to just load the all excel files using the first sheet regardless of its name as it will also be different. that way once it is done I want to move the excel files to a separate location.

VBA to export excel tasks into MS Project

I'm currently trying to create code that will allow myself, and other users of the excel workbook I create, to export tasks, start dates and finish dates from Excel to MS Project.
I've tried a number of ways, without much success.
I've seen that you can simply create and save a map between Excel and Project - however, this will only work for one user. Is there a way to export a map so that all users can use the same map? e.g. saving the map on a shared drive, and getting the code to import tasks into Project using that mapping?
I'm currently saving the Excel output I need to export under the headings the mapping creates:
ID, Outline_Level, Name, Start_Date, Finish_Date.
I've also seen that it is possible to add a task in Project using VBA from Excel. However, I could not find a way to state the start date and finish date. Ideally, I would like a macro in Excel which reads down a list of tasks, and adds them one by one into MS Project, exporting the Start and Finish dates.
I know it would be quicker to do this all in one go, but I will not be using it for a huge array of tasks per project.
Any help is well received! Thanks in advance!

Excel, vba, and onedrive or sharepoint file sharing

I have two local excel files on my hard drive. Both have Macros to achieve certain goals. But after all being done the end result is that after i click a command button from one excel file (lets call it 'A') the data gets transferred based on a macro behind that command button to the other file (let call this one 'B') in a certain format.
All this works great. The source file 'A' is accessible by everyone to enter data, but the destination file to maintain data integrity is read only but a macro is able to write into it. For obvious reasons, both file are on a shared folder so data can be entered one file and transferred to another by everyone.
Now I want to be able to continue with the same functionality but now on a sharepoint or onedrive. Unfortunately I am unable to do so.
I am not sure what are your exact requirements, however I think you can use SharePoint lists with SPD workflows to meet your requirements instead of using excels.
Whenever business users need data in excel they can always export them from list.
There is one more easy way where you can let users enter data in excel however it will be stored in SharePoint list.

Can you schedule periodic data imports in VBA?

I have a VBA function that, when invoked via a button on a sheet, extracts a .csv file from a website and imports it into my workbook. The problem is the file is uploaded in different time intervals during the day, so I have to periodically check the website.
Is there a way in VBA that I can schedule when a function is invoked?
You can use the Application.OnTime() method which will allow you to schedule a Macro for a specific time amongst other settings. However you're probably best using VB Script or similar.
It's also important to note that the workbook would need to be open the entire time if you are going to use VBA, whereas a VBS file will run silently and can be triggered to run at startup.
If you're proficient enough with VBA then you shouldn't have a problem writing VBS.

VB.net text -> Excel conversion (with extensive formatting required after conversion)

I'm creating a program in VB.net that does the following:
At a high level I receive a file in email, put the attachment in a monitored folder, import the text file to excel, format the excel, and then email the excel file to a list of recipients.
Here is my plan:
Completed: Outlook VBA to monitor all incoming email for specific message. Once message is received drop attached .txt file in a specific network folder.
Completed: (VB.net) Monitor folder, when text file is added begin processing
Not Complete: (VB.net) Import text file to Excel
Not Complete: (VB.net) Format Excel Text file. (add in a row of data, format column headers with color/size, add some blank columns, add data validation to some of the blank columns that allow drop down selections)
Completed: (VB.net) Save file.
Completed: (VB.net) Send file to list of recipients.
Obviously the items above that are not complete are the bulk of the work, but I wanted to get some advice on what some of you think would be the best way to approach something like this. The import and formatting of the file are causing me some problems because I just can't decide what would be the most efficient way to do this.
What I've thought of so far:
The way stated above. Import to excel -> format
Having a template excel that contains all of the formatting already done for me and attempting to transition the data to this document (no clue if/how I can do this). Is it even feasible? Have the template already created and then import the text file to a new excel file, then transition that data to the excel template?
Something I thought about, in terms of formatting the document, was to record a macro of me doing all of the formatting that I'm going to need and then attempt to convert that macro into my vb.net code, but I'm not sure if that will work. I will need to verify that the text file comes in the EXACT format every time correct?
I really appreciate any advice/suggestions that anyone is willing to give.
You will want to use http://epplus.codeplex.com/
It allows you to create an Excel file from scratch, without having to start Excel itself. Automating Excel will make the process slow and it lacks robustness (Excel process can hang or not close properly).
In addition, using a .Net library allows you to run it on a server or so where no Excel is installed. (Next step would be to inspect the mailbox via POP, IMAP or the Exchange API, so that part doesn't have to be run on a client machine either)
http://msdn.microsoft.com/en-us/library/kh3965hw(v=vs.100).aspx
You can also just use the Interops from MS to interact with Excel, Outlook, Word, etc. They're not difficult at all to use. I'm not familiar with CodePlex, so that may be a better route or an easier one. I just wanted to provide you with an alternative.
With Microsoft Office 2010 Interops you can not generate Office files from .net applications anymore.
You can manipulate data from existing Excel files so you need templates(your 4th point). Then Excel allows you to query some databases. You may be able to simulate one with your folder, otherwise I suggest to convert your .txt files into some databases. (3rd point)
If you do use an older version, you can crate your Excel files by loading them into an instance of Excel and manipulating them as you wish.
By the way I supposed your attached files would have some sort of format.
If you want to manipulate Excel files, I can recommand you the NPOI library found on CodePlex. It has several advantages over OLE-automation:
NPOI is not dependent on a specific Excel version.
Excel (or any other Office component) need not to be installed.
It is faster.
It works with both .XLS and .XLSX files.
We are using a third party software called excel writer. May not be what you are looking for becauseit needs to be license, but it is very fast and the clients does not have to wait for a chart or a data output. Because we have that tool, have not try anything else.