Update information in teams file from excel workbook

Tanyaann1995

Board Regular
Joined
Mar 24, 2021
Messages
62
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I want to link an Excel workbook to a file in Teams and update some information in the Teams file from the workbook in desktop. I want to add some information in a Teams file from an Excel workbook in the desktop by linking those two.

This is the code i created:

VBA Code:
Dim xx As Object
Set wb = ActiveWorkbook
sFileName = "https://emerson.sharepoint.com/sites/PRVOrders/Shared%20Documents/General/TAT.xlsx"
Set xx = CreateObject("Excel.Application")
Set f = xx.Application.Workbooks.Open(Filename:=sFileName, ReadOnly:=False)

lastrow = f.Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row + 1
f.Worksheets(1).Cells(lastrow, "A").Value = wb.Worksheets("Order Entry Form").Range("F13").Value
f.Worksheets(1).Cells(lastrow, "B").Value = wb.Worksheets("Order Entry Form").Range("D13").Value
f.Worksheets(1).Cells(lastrow, "C").Value = wb.Worksheets("Order Entry Form").Range("D21").Value
f.Worksheets(1).Cells(lastrow, "D").Value = wb.Worksheets("Order Entry Form").Range("D9").Value
f.Worksheets(1).Cells(lastrow, "E").Value = Date
f.Worksheets(1).Cells(lastrow, "F").Value = wb.Worksheets("Order Entry Form").Range("D15").Value
f.Worksheets(1).Cells(lastrow, "G").Value = wb.Worksheets("Order Entry Form").Range("D7").Value
f.Worksheets(1).Cells(lastrow, "H").Value = wb.Worksheets("Order Entry Form").Range("F19").Value
f.Worksheets(1).Cells(lastrow, "I").Value = wb.Worksheets("Order Entry Form").Range("F9").Value
f.Worksheets(1).Cells(lastrow, "L").Value = wb.Worksheets("Checklist").Range("B20").Value
f.Worksheets(1).Cells(lastrow, "M").Value = wb.Worksheets("Order Entry Form").Range("O9").Value
f.Worksheets(1).Cells(lastrow, "N").Value = wb.Worksheets("ENQUIRY - ORDER REVIEW").Range("F27").Value
f.Worksheets(1).Cells(lastrow, "O").Value = "PRV"

f.Close savechanges:=True
Set f = Nothing
Capture2222.PNG


When the teams file is updated with all the information, it has to close and save. The problem here is the above pop up comes up asking to save as another copy instead of updating in the same file. I dont want to create a copy, i just want the code to update in the same file in Teams but instead it creates a copy. Is there any way to fix this?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi,

I want to link an Excel workbook to a file in Teams and update some information in the Teams file from the workbook in desktop. I want to add some information in a Teams file from an Excel workbook in the desktop by linking those two.

This is the code i created:

VBA Code:
Dim xx As Object
Set wb = ActiveWorkbook
sFileName = "https://emerson.sharepoint.com/sites/PRVOrders/Shared%20Documents/General/TAT.xlsx"
Set xx = CreateObject("Excel.Application")
Set f = xx.Application.Workbooks.Open(Filename:=sFileName, ReadOnly:=False)

lastrow = f.Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row + 1
f.Worksheets(1).Cells(lastrow, "A").Value = wb.Worksheets("Order Entry Form").Range("F13").Value
f.Worksheets(1).Cells(lastrow, "B").Value = wb.Worksheets("Order Entry Form").Range("D13").Value
f.Worksheets(1).Cells(lastrow, "C").Value = wb.Worksheets("Order Entry Form").Range("D21").Value
f.Worksheets(1).Cells(lastrow, "D").Value = wb.Worksheets("Order Entry Form").Range("D9").Value
f.Worksheets(1).Cells(lastrow, "E").Value = Date
f.Worksheets(1).Cells(lastrow, "F").Value = wb.Worksheets("Order Entry Form").Range("D15").Value
f.Worksheets(1).Cells(lastrow, "G").Value = wb.Worksheets("Order Entry Form").Range("D7").Value
f.Worksheets(1).Cells(lastrow, "H").Value = wb.Worksheets("Order Entry Form").Range("F19").Value
f.Worksheets(1).Cells(lastrow, "I").Value = wb.Worksheets("Order Entry Form").Range("F9").Value
f.Worksheets(1).Cells(lastrow, "L").Value = wb.Worksheets("Checklist").Range("B20").Value
f.Worksheets(1).Cells(lastrow, "M").Value = wb.Worksheets("Order Entry Form").Range("O9").Value
f.Worksheets(1).Cells(lastrow, "N").Value = wb.Worksheets("ENQUIRY - ORDER REVIEW").Range("F27").Value
f.Worksheets(1).Cells(lastrow, "O").Value = "PRV"

f.Close savechanges:=True
Set f = Nothing
View attachment 93987

When the teams file is updated with all the information, it has to close and save. The problem here is the above pop up comes up asking to save as another copy instead of updating in the same file. I dont want to create a copy, i just want the code to update in the same file in Teams but instead it creates a copy. Is there any way to fix this?
Hi,

Please help with above urgently.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top