1 Replies - 211 Views - Last Post: 05 January 2019 - 09:48 AM Rate Topic: -----

#1 [email protected]   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-January 19

Run code based on file imported

Posted 04 January 2019 - 04:06 PM

I am re-working my program to make things a bit easier. I am a low-end experienced coder. My request for help is as follows:

I create a CSV file from a PDF my employees use and once the PDF is converted to csv I import the .csv into my program. No issues there.

I am needing, however, to chose the specific code to run based on a specific file chosen. As an example:

I generate 3 similiar reports. 1_report2019001.csv, 2_report2019001.csv or 3_report2019001.csv. Each form is pretty much mirrors of each other, with the largest difference is the amount of pages with data being imported.

SO I need to come up with code that if 1_report2019001.csv is being imported than run this code... If 2_report2019001.csv is imported, then run this code, etc.

One issue is a dialog box is opened and the form is chosen then imported. SO I am not sure how to code in if 1_report2019001.csv is chosen then run this code, if 2_report2019001.csv is chosen then run this code etc.

I'm thinking I need to assign a variable for the report name that has been chosen and then pass that variable to the Select case or StartsWith statement. Not clear on how to assign or capture the filename chosen.

Then, assuming I can pass a variable to the Select Case or Startwith function.

I think I can use a case argument similar to "Select Case True case value.StartsWith("1_") .... code ...."

I'm wondering if this is a solid idea or is there a better way to determine which file is being imported then run specific code for that form?

I hope this is clear and concise... I tend to overthink and try to express what I'm thinking into text.

Is This A Good Question/Topic? 0
  • +

Replies To: Run code based on file imported

#2 modi123_1   User is offline

  • Suitor #2
  • member icon

Reputation: 14771
  • View blog
  • Posts: 59,047
  • Joined: 12-June 08

Re: Run code based on file imported

Posted 05 January 2019 - 09:48 AM

In the 'file chooser dialog box' thing control it has the file name. You should be able to use 'path.filename' to get the name and do what ever after.

Seems a little hacky, but I would almost go the extra step to put the onus on what file is being picked on the user.. so they need to click a radio button, or a drop down, to say 'hey, I am for certain I am using this file'.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1