Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:05:19+00:00 2026-06-13T04:05:19+00:00

This question has been edited due to lengthy comments and updates from proposed answers.

  • 0

This question has been edited due to lengthy comments and updates from proposed answers.

As requested here is module 13;

Sub SaveInFormat()
Application.DisplayAlerts = False
Workbooks.Application.ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\jammil\Desktop\AutoFinance\ProjectControl\Data\" & Format(Date, "yyyymm") & "DB" & ".xlsx",   leFormat:=51
Application.DisplayAlerts = True
End Sub

Also there are issues with the errorhandling, I know I’ve gone wrong with it but I’m more interested in fixing the close function at the moment before I get into it. Here is the error handling code that needs some work

Sub test()

Dim wk As String, yr As String, fname As String, fpath As String
Dim owb As Workbook

wk = ComboBox1.Value
yr = ComboBox2.Value
fname = yr & "W" & wk
fpath = "C:\Documents and Settings\jammil\Desktop\AutoFinance\ProjectControl\Data"
owb = Application.Workbooks.Open(fpath & "\" & fname)
On Error GoTo ErrorHandler:
ErrorHandler:
If MsgBox("This File Does Not Exist!", vbRetryCancel) = vbCancel Then Exit Sub Else Call Clear

'Do Some Stuff

Call Module13.SaveInFormat

owb.Close

this is your test code plus my changing of the file path and name

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:05:20+00:00Added an answer on June 13, 2026 at 4:05 am

    After discussion posting updated answer:

    Option Explicit
    Sub test()
    
        Dim wk As String, yr As String
        Dim fname As String, fpath As String
        Dim owb As Workbook
    
        With Application
            .DisplayAlerts = False
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        wk = ComboBox1.Value
        yr = ComboBox2.Value
        fname = yr & "W" & wk
        fpath = "C:\Documents and Settings\jammil\Desktop\AutoFinance\ProjectControl\Data"
    
        On Error GoTo ErrorHandler
        Set owb = Application.Workbooks.Open(fpath & "\" & fname)
    
        'Do Some Stuff
    
        With owb
            .SaveAs fpath & Format(Date, "yyyymm") & "DB" & ".xlsx", 51
            .Close
        End With
    
        With Application
            .DisplayAlerts = True
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    
    Exit Sub
    ErrorHandler: If MsgBox("This File Does Not Exist!", vbRetryCancel) = vbCancel Then
    
    Else: Call Clear
    
    End Sub
    

    Error Handling:

    You could try something like this to catch a specific error:

        On Error Resume Next
        Set owb = Application.Workbooks.Open(fpath & "\" & fname)
        If Err.Number = 1004 Then
        GoTo FileNotFound
        Else
        End If
    
        ...
        Exit Sub
        FileNotFound: If MsgBox("This File Does Not Exist!", vbRetryCancel) = vbCancel Then
    
        Else: Call Clear
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Warning: This question has been heavily edited. I tried my best to guess the
NB: This question has been extensively edited to make it more relevant, for completeness
This question has been puzzling me for a long time now. I come from
This question has been asked before but the answers aren't always clear or are
** This question has been edited to make it simpler and more focused **
This question has been edited for clarification: I am trying to create "pretty URLs"
N.B This question has been significantly edited before the first answer was given. Hi,
This question has been edited to ask about a specific example as the original
This question has been edited: I am working with QML. I have a custom
This question has been asked before but i still don't understand it fully so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.