Help Please. How to save multiple html files (sounds easy but scenario causing confli

S

sam76210

Hello Group!
Here is my scenario. I use third party software to dump data (running
every hr) into excel. The following code works fine as far as saving
file as an html with time stamp;

ChDir "C:\SFC\Archived\"
ActiveWorkbook.SaveAs Filename:="C:\SFC\Archived\" & fname &
"_chem" & ".html", FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False

It works fine by saving file as 03-24-06_chem.html. Now when I used the
next code after the above code to save same excel file with given name
as an html;

ChDir "C:\SFC\" 'default directory for chem 7 days

ActiveWorkbook.SaveAs Filename:="C:\SFC\chem-gas.html",
FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False

It does save the file as chem-gas.html but dropping the new data.

Here what i tried;

I tried saving file;

ActiveWorkbook.Save before running the above codes. Didn’t work.
Since the excel has graph, i have to have FileFormat:=XLHtml. It does
create a foler with all gif files in it.

I was wondering some how if I can save both files by using the first
code than i might not loss the data for the second file creation.


Here is my complete macro coding;

Sub chem7day()


Dim newSecond
Dim fname As String
Dim i As Long

fname = Format(Date, "yyyy-mm-dd")
newSecond = Second(Now()) + 60 'Time Delay


Calculate 'Calculating all
sheets including updating charts with new data
ActiveWorkbook.Save 'Saving file as an
Excel format



Sheets("2006").Select 'Before saving file the
main sheet should be default
Range("A2").Select 'Placing cursor to
upper left


If Weekday(Date) = 5 Then 'Condition to save
file every Wednesday



ChDir "C:\SFC\Archived\"
ActiveWorkbook.SaveAs Filename:="C:\SFC\Archived\" & fname &
"_chem" & ".html", FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False
'If condition true than saving file with current date with addition
file name


‘The following code saving the file but without new data

ChDir "C:\SFC\" 'default directory for chem 7 days

ActiveWorkbook.SaveAs Filename:="C:\SFC\chem-gas.html",
FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False




Else



ChDir "C:\SFC\" 'default directory for chem 7 days

ActiveWorkbook.SaveAs Filename:="C:\SFC\chem-gas.html",
FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=Fal 'If this
condition true than saving file as an html with given name




End If
End Sub
 

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

Similar Threads


Top