Advertisement

07.02.2008 at 09:38PM PDT, ID: 23535838
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

Using VBA to delete an existing .htm file from a directory prior to saving an updated version into its place.

Asked by melcleary20 in Microsoft Excel Spreadsheet Software

Tags:

My question regards a process I am trying to develop for an excercise that must be performed 3-25 times per day.  Basically we track approx 2200 stock using Excel's RTD functionality.  At sporadic times during the market day, our monitoring formulas will detect trading entry conditions, extract those conditions and add them to a sheet in the workbook named "2 Alert Report".

With the coding below, we're able to perform the following actions
1    turn DisplayAlerts off
2    select "2 Alert Report" sheet, hide specific columns
3    copy "2 Alert Report" sheet to a new book
4    change directories and save the "new book" as "dar_current.htm"
5    turn DisplayAlerts back on

Everything works well on the first pass since the is no previously existing "dar_current.htm" file

So what I am having trouble figuring out is how to use VBA form within my macro to delete an existing "dar_current.htm" file from a directory prior to saving an updated version into its place.

Thanks in advance for any guidance you could share with me.
Ed
I have attached my code below:
Sub a105__Move_ALERT_REPORT_Sheet_to_SMOOTHTRADES_Directory_for_Webposting()

'TURN REFRESH & ALERTS OFF
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.Calculation = xlCalculationManual
   
'SELECT "ALERT REPORT" and HIDE SPECIFICS COLUMNS
    Sheets("2 Alert Report").Select
    Range("E:E,F:F,G:G,H:H,J:J,K:K,L:L,N:N,V:V,Y:Y,AA:AA,AB:AB,AC:AC").Select
    Range("AC1").Activate
    Selection.EntireColumn.Hidden = True
   
'COPY ALERT REPORT SHEET to NEW BOOK
    Sheets("2 Alert Report").Select
    Sheets("2 Alert Report").Copy
   
'????
'Is there a way I could DELETE the file named dar_current.htm (located at the pathway below)
'so that the "save as" statements will not need to overwrite the previously existing file?
   
    ChDir "C:\Program Files\Yahoo SiteBuilder\sites\sites\smoothtrades.com"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Program Files\Yahoo SiteBuilder\sites\sites\smoothtrades.com\dar_current.htm" _
        , FileFormat:=xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False

'RETURN TO PREVIOUS WINDOW and CONTINUE PROCESSING
    Windows("S3_Watch.xlsm").Activate
        ActiveWindow.WindowState = xlNormal
        ActiveWindow.WindowState = xlNormal
    Range("A1").Select

'TURN REFRESH & ALERTS BACK ON
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.Calculation = xlCalculationAutomatic
   
End Sub





Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
Sub a105__Move_ALERT_REPORT_Sheet_to_SMOOTHTRADES_Directory_for_Webposting()
 
'TURN REFRESH & ALERTS OFF
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.Calculation = xlCalculationManual
    
'SELECT "ALERT REPORT" and HIDE SPECIFICS COLUMNS
    Sheets("2 Alert Report").Select
    Range("E:E,F:F,G:G,H:H,J:J,K:K,L:L,N:N,V:V,Y:Y,AA:AA,AB:AB,AC:AC").Select
    Range("AC1").Activate
    Selection.EntireColumn.Hidden = True
    
'COPY ALERT REPORT SHEET to NEW BOOK
    Sheets("2 Alert Report").Select
    Sheets("2 Alert Report").Copy
    
'????
'Is there a way I could DELETE the file named dar_current.htm (located at the pathway below)
'so that the "save as" statements will not need to overwrite the previously existing file?
    
    ChDir "C:\Program Files\Yahoo SiteBuilder\sites\sites\smoothtrades.com"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Program Files\Yahoo SiteBuilder\sites\sites\smoothtrades.com\dar_current.htm" _
        , FileFormat:=xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False
 
'RETURN TO PREVIOUS WINDOW and CONTINUE PROCESSING
    Windows("S3_Watch.xlsm").Activate
        ActiveWindow.WindowState = xlNormal
        ActiveWindow.WindowState = xlNormal
    Range("A1").Select
 
'TURN REFRESH & ALERTS BACK ON
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.Calculation = xlCalculationAutomatic
    
End Sub
[+][-]07.02.2008 at 10:19PM PDT, ID: 21922809

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.02.2008 at 10:27PM PDT, ID: 21922853

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.20.2008 at 11:09AM PDT, ID: 22046443

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Excel Spreadsheet Software
Tags: Excel VBA
Sign Up Now!
Solution Provided By: c0ldfyr3
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628