MSAccess VBA - Within a Function, copy a sheet1 and then paste values back in sheet 1

I am trying to change all of the formulas in Sheet1 of an Excel Workbook to the values. After this, I will save the workbook under a new name. Can someone please help with the code below. I have commented out in Step 4 what I wrote that does not work.

Thank you

Function ExcelTest()

   
 
    Dim xl As Object
     
    'Step 1:  Start Excel, then open the target workbook.
       Set xl = CreateObject("Excel.Application")
        xl.workbooks.Open ("C:\Users\rrudo_000\Dropbox\TBCO\BMA_OtherInfo\Cash_Template.xlsx")
     
    'Step 2:  Make Excel visible
       xl.Visible = True
     
    'Step 3:  Refresh the data
       xl.activeworkbook.Refreshall
     
    'Step 4:  Save the Cash_Template as a different file name
       ' xl.activeworkbook.sheets("Sheet1").copy
       ' xl.activeworkbook.sheets("Sheet1").PasteSpecial xlPasteValues
       xl.activeworkbook.saveas ("C:\Users\rrudo_000\Dropbox\TBCO\BMA_OtherInfo\TestNewCash_Template.xlsx")
       
       xl.activeworkbook.Close (True)
        xl.Quit
     
    'Step 5:  Memory Clean up.
       Set xl = Nothing
     





End Function
Rick RudolphAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
BHI,

pls try

 
     Dim xl As Object
      
     'Step 1:  Start Excel, then open the target workbook.
        Set xl = CreateObject("Excel.Application")
         xl.workbooks.Open ("C:\Users\rrudo_000\Dropbox\TBCO\BMA_OtherInfo\Cash_Template.xlsx")
      
     'Step 2:  Make Excel visible
        xl.Visible = True
      
     'Step 3:  Refresh the data
        xl.activeworkbook.Refreshall
      
     'Step 4:  Save the Cash_Template as a different file name
        xl.activeworkbook.sheets("Sheet1").UsedRange.Value = xl.activeworkbook.sheets("Sheet1").UsedRange.Value
        ' xl.activeworkbook.sheets("Sheet1").PasteSpecial xlPasteValues
        xl.activeworkbook.saveas ("C:\Users\rrudo_000\Dropbox\TBCO\BMA_OtherInfo\TestNewCash_Template.xlsx")
        
        xl.activeworkbook.Close (True)
         xl.Quit
      
     'Step 5:  Memory Clean up.
        Set xl = Nothing

Open in new window

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rick RudolphAuthor Commented:
Excellent, can you point me to a resource that would have explained this to me as well as other options for methods and workbooks?
0
Rgonzo1971Commented:
Could you be more precise
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Rick RudolphAuthor Commented:
I had real problems trying to google methods I could use in an MSAcess VBA module to manipulate an Excel spreadsheet
0
Rgonzo1971Commented:
AS soon as you have set the Excel Application object
Set xl = CreateObject("Excel.Application")  ' = Application in excel
the Excel Object is open to you so you can search for Excel VBA ( no need to reference Access in your search)
0
Rick RudolphAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.