Chart2JPG and export to webpage directory

E

erooijackers

Morning,

I am building an Excel workbook to automaticly update my website by
clicking a macro. For publishing of my data i have a good working VBA
code but the related graphs to this data should be published as well.
So, in order to do that i wanted to add this code (see below).
This VBA code works perfectly in a local directory environment (C / D
drive). But i want to save it to: http://servername/myhomepage/randomdir.
Replacing the desktop directory with the http directory does not work.
Does anyone have a solution



Sub ExportChart2JPG()

Sheets("Graphs").Select
ActiveSheet.ChartObjects("Grafiek 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.Export Filename:="C:\Documents and Settings\Erik\Desktop
\Grafiek2.jpg", _
FilterName:="jpeg"

End Sub
 
P

Peter T

Try exporting it as a .gif and don't include the 'FilterName' argument at
all, or FilterName as an empty string, "".

Regards,
Peter T
 
E

erooijackers

I tried it with the following code but still no succes. Any more
suggestions or is my code faulty?


<u>Quote of error message:</u>
Error 1004 during execution
Export of object_chart failes

<u>VBA Code used:</u>
Sub ExportChart2JPG()

Sheets("Graphs").Select
ActiveSheet.ChartObjects("Grafiek 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.Export Filename:="http://ehvtintra/ehv-hog/Energy and
%20Emissions%20SSI/Excel/Grafiek2.gif"

End Sub








Peter T schreef:
 
P

Peter T

The export chart method can be problematic with the Filtername argument
included, but it seems that's not the cause of your problem. Your code looks
OK but I can't test saving to a server. BTW, you don't need to select the
chart, eg

Sheets("Graphs").ChartObjects("Grafiek 2").Chart.Export sFileName

Try exporting to your local drive first, then copy or upload the file to
your server.

If that works, and you particularly want to save as a jpg try that as well.
But even with .jpg you can probably drop the FilterName argument. FWIW
charts are generally better suited to gif's rather than jpg's, unless they
include particular images.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top