Rootdir function is not working in 2010 VBA

misterno

Board Regular
Joined
Mar 16, 2009
Messages
78
Here is that I have


rootDir = "M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily Graphs"

Please help
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Sorry this is a better one. VBA stops at rootdir. But before when I was using excel 2007, it was working fine, Now we are using excel 2010.

-----------
Code:
rootDir = "M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily Graphs"
Set ws = ActiveWorkbook.Sheets("AGT-TM3")
ws.ChartObjects(1).Chart.Export rootDir & "\AGT & TM3" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("NBP")
ws.ChartObjects(1).Chart.Export rootDir & "\NBP" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("NBP")
ws.ChartObjects(2).Chart.Export rootDir & "\NBP1" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("NBP2")
ws.ChartObjects(1).Chart.Export rootDir & "\NBP2" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("Brent")
ws.ChartObjects(1).Chart.Export rootDir & "\Brent_year" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("GBP")
ws.ChartObjects(1).Chart.Export rootDir & "\GBP" & ".jpg", "JPG"
 
Last edited by a moderator:
Upvote 0
How does it 'stop'?

Do you get any error messages?

Have you declared rootdir?
 
Upvote 0
How does it 'stop'?

Do you get any error messages?

Have you declared rootdir?

It stops at "rootdir ="

Yes I got an error message "compile error can't find project or library"

And yes I declared rootdir. (look at the first line of the code)

rootDir = "M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily Graphs"



I think 2010 Excel VBA does not have rootdir function, just a guess
 
Upvote 0
There is no rootdir function in VBA.

You aren't declaring rootdir anywhere in the code you posted.

Can you post the rest of the code?
 
Upvote 0
What do you mean? I have been running this macro for years and rootdir is a part of it. I am posting again. Please look at the first line.

Code:
rootDir = "M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily Graphs"
Set ws = ActiveWorkbook.Sheets("AGT-TM3")
ws.ChartObjects(1).Chart.Export rootDir & "\AGT & TM3" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("NBP")
ws.ChartObjects(1).Chart.Export rootDir & "\NBP" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("NBP")
ws.ChartObjects(2).Chart.Export rootDir & "\NBP1" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("NBP2")
ws.ChartObjects(1).Chart.Export rootDir & "\NBP2" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("Brent")
ws.ChartObjects(1).Chart.Export rootDir & "\Brent_year" & ".jpg", "JPG"
Set ws = ActiveWorkbook.Sheets("GBP")
ws.ChartObjects(1).Chart.Export rootDir & "\GBP" & ".jpg", "JPG"
 
Last edited by a moderator:
Upvote 0
The first line is not a declaration line, it's where you assign a value.
Code:
Dim rootDir as String
would be a declaration line - i.e. where you declare the variable.
 
Upvote 0
The first line is not a declaration line, it's where you assign a value.
Code:
Dim rootDir as String
would be a declaration line - i.e. where you declare the variable.

Thanks

I guess that line got deleted or missing somehow

When I added "
Dim rootDir as String</PRE>
it worked fine

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

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