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 8484757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:27:44+00:00 2026-06-10T20:27:44+00:00

As it stands now I have it written up where the code creates a

  • 0

As it stands now I have it written up where the code creates a file in the folder that the original file exists in. Once the file is created, I want to have it where wbBK2 is defined as the file that was just created. I figured using the same code to create the file, minus the SaveAs option would work, but it seems that it doesn’t like the object.

Is there a reason why? For all intended purposes it should be pointing directly at the file, but it seems to not agree… can someone see the mistake I’ve made?

Option Explicit

Sub OpenOrderReportExport()

    Dim wsJL As Worksheet   'Jobs List
    Dim wsPOT As Worksheet  'PO Tracking
    Dim wsTNO As Worksheet  'Tel-Nexx OOR
    Dim wbBK2 As Workbook   'New Workbook
    Dim wsWS1 As Worksheet  'Sheet1
    Dim wsWS2 As Worksheet  'Sheet2
    Dim wsWS3 As Worksheet  'Sheet3
    Dim CurrentFile As String, NewFileType As String, NewFile As String, Dir As String


    Set wsJL = Sheets("Jobs List")      'Jobs List
    Set wsPOT = Sheets("PO Tracking")   'PO Tracking
    Set wsTNO = Sheets("Tel-Nexx OOR")  'Tel-Nexx OOR
    Set wbBK2 = Workbooks.Add           'New Workbook
    Set wsWS1 = wbBK2.Sheets("Sheet1")  'Sheet1
    Set wsWS2 = wbBK2.Sheets("Sheet2")  'Sheet2
    Set wsWS3 = wbBK2.Sheets("Sheet3")  'Sheet3

        Application.ScreenUpdating = False    ' Prevents screen refreshing.
        CurrentFile = ThisWorkbook.FullName
        NewFileType = "Excel Files 2007 (*.xlsx)"
        Dir = ThisWorkbook.path
        wbBK2.SaveAs Dir & Application.PathSeparator & "Open Order Report -" & Format(Date, "mm-dd-yyyy") & ".xlsx"
        Set wbBK2 = Dir & Application.PathSeparator & "Open Order Report -" & Format(Date, "mm-dd-yyyy") & ".xlsx"

        MsgBox wbBK2
End Sub
  • 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-10T20:27:45+00:00Added an answer on June 10, 2026 at 8:27 pm

    As already hinted at in the comments Dir & Application.PathSeparator & "Open Order Report -" & Format(Date, "mm-dd-yyyy") & ".xlsx" does not create an object. That code returns a string, which is an ordinary data type in VBA.

    The error occurs when you use set wbBK2 = the code above, because set requires an object to reference.

    As an aside, as Siddharth Rout already pointed out, you actually correctly created the reference to the work book with this line Set wbBK2 = Workbooks.Add so a further set line is unnecessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using XSL-FO to create PDF's. Now I have a label that I want
first, I can't stand Crystal! Okay, that's off my chest... Now, we have an
As it stands, I have a deserialiser that can import any model I throw
I have been optimizing my website but the one problem that stands in my
I have code that launches an external application and automatically fills in a password
In the past I have written C++ plugins that detoured the recvfrom() function in
I have a typical Flex-based application that was written to use a Java/Hibernate/MySQL backend.
I have written an OpenGL game and I want to allow remote playing of
I have a model that, when it instantiates an object, also creates another object
I have a problem that involves biology area. Right now I have 4 VERY

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.