Learner Learner - 1 year ago 75
Vb.net Question

Remove Hard coding of 'file path' in Excel while calling the other workbook

I'm new to the VB coding so please help me.

I have an Excel where in the code the filename is hard coded with the file path. File name stays the same every time but the path does changes from time to time so, is there a way that we can say define the file path to look into the current directory that the calling workbook is in?

If not at worst I think we have to give the path in one of the excel columns and refer it in the code. Current code as follows:

Workbooks.Open Filename:= _

Any help is highly appreciated.

Answer Source

You can extract the current file path using the method:

strFileDir = ThisWorkbook.Path


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download