Problem with macro for opening a workbook

geometrisk

New Member
Joined
Jul 8, 2011
Messages
2
Hi <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
I’m having a problem with my macro. <o:p></o:p>
<o:p></o:p>
The process consists of to workbooks, “corrective action” and “corrective action oversight”, the macro saves some values from “corrective action” to “corrective action oversight”.<o:p></o:p>
<o:p></o:p>
The 2 workbooks will always be I the same folder, but may not always have the same path on all computers; therefore I used the following code:
<o:p></o:p>
<o:p></o:p>
<o:p>
Code:
<o:p>ChDir (ActiveWorkbook.path)
Workbooks.Open Filename:="Corrective action Oversigt.xls"
</o:p>
</o:p>
<o:p></o:p>
<o:p></o:p>
The macro works fine when the files are on my C drive, but when they are moved to the network I get an error on the second line.<o:p></o:p>
<o:p></o:p>
If I substitute the code with the direct path on the network the macro works. :confused:


Please help <o:p></o:p>
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
It got it to work using the following code

Code:
    Dim vFile As Variant
    vFile = ActiveWorkbook.path & "\" & "Corrective action Oversigt.xls"
        Workbooks.Open vFile
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top