Solved

Close a .CSV File when the name of the file changes daily

Posted on 2014-03-10
7
242 Views
Last Modified: 2014-03-11
Hello Experts,

I am trying to cut down on the amount of effort I have to do in getting files into a directory, changing their name and then automatically importing the file data into a Excel spreadsheet.

Each day I get a file called Unsuccessful_Account_Validation[previous days date], for example Unsuccessful_Account_Validation_Mar_10_2014.  I can get the file by using vPath = Application.GetOpenFilename("CSV (Comma Delimited) (*.csv),*.csv"

But because the file name is dynamic I cannot close the file using  Windows(filename.csv").Activate
ActiveWindow.close

Any help you could give me would be greatly appreciated.

Regards,
InfoSec36
0
Comment
Question by:Sonia Bowditch
  • 4
  • 2
7 Comments
 
LVL 39

Expert Comment

by:nutsch
ID: 39918376
How about

dim wbkCSV as workbook
vPath = Application.GetOpenFilename("CSV (Comma Delimited) (*.csv),*.csv"

wbkCSV=workbooks.open(vPath)
'do your stuff here

wbkCSV.close(false)

Open in new window

0
 
LVL 25

Expert Comment

by:SStory
ID: 39918387
If the data is a CSV and the same format every day and comes without headers, I'd change it from .xls to a simple .CSV and append the data to the CSV file.

So Example:
MainFile.csv                     (Excel and LibreOffice or any spreadsheet can read this)

NewFileWhateverName.CSV

From the commandline
Type NewFileWhateverName.CSV >> MainFile.csv

the >> will concatenate (append the data in NewFileWhateverName.CSV to MainFile.csv

You can then open that file...or not, but the data will be there.
0
 

Author Comment

by:Sonia Bowditch
ID: 39918421
Hello nutsch,

Thanks for getting back to me so quickly.  

I can't get it to work.  For some reason it falls over at wbkCSV=workbooks.open(vPath).  The message I get is 'Object doesn't support this property or method'.

Regards,
InfoSec36
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:Sonia Bowditch
ID: 39918427
Hello SStory,

The .CSV files I get each day are imported into Excel for further formatting and analysis.  

Regards,
InfoSec36
0
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 39918723
My bad, try instead

Set wbkCSV=workbooks.open(vPath)
0
 

Author Comment

by:Sonia Bowditch
ID: 39919948
Hello Nutsch,

I am getting an object required error when it hits:-

wbkCSV = Workbooks.Open(vPath)


Regards,
InfoSec36
0
 

Author Closing Comment

by:Sonia Bowditch
ID: 39920339
Thanks Nutsch,

I did a bit of fiddling with my code and got it to work.

Thank you so much.

Regards,
InfoSec36
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question