Excel SaveAs trying to replace files after running a VBA macro -


I created macros using Excel 2013.

What does the macro do by default:

  • Create a workbook to consolidate SAP data
  • Remove data from SAP in a floating sheet (many Times), then copies data from the temporary sheet for the workbook.
  • Format the workbook with the extracted data and keep it

The macro runs fine, but after it's finished, when I "File -> Save as "or click on" File -> Open "and try to select a folder on any Excel workbooks, which are open to me, to display a folder, the display and the file are not visible Will try, and try to save all Is a message that is a message "already has a file named" xxxxx.xls "in the folder. Do you want to change" I do not understand "that Excel now lets me save or open files Why not allow to select until I close the application.

I tested the macro in Excel 2003, and there was no problem. Is this office 2013 bug or something like this? ?

I code Tried to remove irrelevant parts, except for non-SAP parts:

  A result of the WB Workbook Private Sub CreateEndItensWB () creates an empty WB set of newWB = Workbooks.Add ' Name changes sheet newWB.Sheets (1) .Name = "end iTENS" set eiSheet = newWB.Sheets' creates a header ("iTENS end") data table eiSheet.Range ("A1") = "nivel" eiSheet. Range ("B1") = "PN" eiSheet.Range ("C1") = "COD. EiSheet.Range ("E1") = "Efetividade" eiSheet.Range ("F1") = "ProcedĂȘncia" eiSheet.Range ("G1") for "Emberre" eiSheet.Range ("D1") ) = "ProcedĂȘncia" eiSheet.Range ("H1") = "Parceiro" eiSheet.Range ("I1") = "End Item" 'saves the name of West Bengal newWB.SaveAs file: = "C: \ TEMP \ EndItens" .xls ", fileformat: = 56 newWB.Close End Sub Personal sub buscaDadosNoSAP () '' SAP login data is found '' It's Sheet set AI sheet = set sheets (" end intense ") 'end itens endItens = eiSheet Range set range (.iiSheet.Range ("A2"), eiSheet.Range ("A2") and (xlDown)) 'makes results West Bengal createEndItensWB set resultsWB = Workbooks.Open ("C: \ As Thayi is \ EndItens.xls ") Error GoTo 'ErrorSec' log said in SAP 'on parceiro the final iTENS that loops a sector through endItens' will be extracted from SAP for each endItem, sheet set in parceiro Sign in = endItem.Offset (0, 1) extractData: Error Goto SessionErr 'Turns' SAP uses a SAP session to extract data, and in it saves "C: \ TEMP \ tempEndItens.xls"' Error goto error 'copy tempWB = Workbooks.Open ("C: \ tEM P \ tempEndItens.xls ") 'check if there is the tempWB.Sheets (1) .Range (" B6 ") is the extracted SAP data; & Gt; "" Then "SAP fills in the universe with the data extracted from 'Else'" If there is no mark in the sheet, then it just inserts a line for the item at the end - in the field, pointing to it For that there was no data 'end tempWB.Close (false) next endItem' 'SAP session' if 'format result West Bengal lastRowRes = resultsWB.Sheets ("Final iTENS"). Range ("A65000"). End (xlUp) .Row resultsWB.Sheets ("iTENS End A1: I" & amp; lastRowRes). Borders (xlEdgeLeft) .ight = xlThin resultsWB.Sheets ("last iTENS") range (. "A1:") range ( . "I" & amp; lastRowRes) .Borders (xlEdgeTop) .Weight = xlThin resultsWB.Sheets ( "last iTENS") range ( "A1: I" .. & amp; lastRowRes) .Borders (xlEdgeBottom) .Weight = xlThin resultsWB.Sheets ( "last iTENS") range ( "A1: I" & amp; lastRowRes) .Borders (xlEdgeRight) .Weight = xlThin resultsWB.Sheets ( "last iTENS") range (. "A1: I" & amp; LastRowRes). Borders (xlInsideVertical) .ight = xlThin ResultsWB.Sheets ("And Eten"). Range ("A1: Eye" & LastRowRes). Borders (xlInsideHorizontal) .ight = xlThin resultsWB.Sheets ("Final ITENS") range ("A1: I1" ...) Font.Bold = resultsWB.Sheets (with true ( "last ITENS") range ( "A1: I1") internal .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -0.349986266670736 .PatternTintAndShade = 0 end with resultsWB.Sheets. "iTENS End ") range (." A1 ") Auto Filter ResultsWB.Sheets. ("Ultimate iTENS") Columns.AutoFit 'Result saves the West Bengal resultsWB.Save exit sub errorSec: resultsWB.Close (false) MsgBox ("Error macro running") End SessionErr:'. Refresh SAP session Goto extractData End Sub  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -