473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Document not saved when using VBA in Excel 2010

63
I have an excel 97-2003 file called "MASTER - FX Reconciliations Modelvista.xls" that I open using Excel 2010. Within this file I run a VBA macro with the name FXcurr. This macro picks up a file called rollifrp.xls (97-2003 Worksheet) makes some amendments to it and then saves it down to a file path detarmined by the entries in two cells of the MASTER - FX Reconciliations Modelvista.xls file. The macro errors and returns a "Document not saved" "Run time error 1004" message. When I debug I can run past the errro using the "run to cursor" option - this then saves down the file as per the the code insructions, saving down the rollifrp.xls file in the right location as a 97-2003 file (we are set to run in compatibility mode). How do I get rid of the error message that appears - as I don't want to have to keep having to debug, go into the code select a line beyond the error and run to cursor each time. This has been driving me crazy - if you could help that would be great!



The problem line within the code is this part:

Expand|Select|Wrap|Line Numbers
  1.  Windows("rollifrp.xls").Activate
  2.     Columns("A:L").Select
  3.     Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
  4.         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
  5.     If AP.Value < 10 Then
  6.         stDocName = "Q:\Reports\Financial Reporting\IFRS\" & CurrYr & "\AP0" & AP.Value & "\04_Models\rollifrp AP0" & AP.Value & ".xls"
  7.     Else
  8.         stDocName = "Q:\Reports\Financial Reporting\IFRS\" & CurrYr & "\AP" & AP.Value & "\04_Models\rollifrp AP" & AP.Value & ".xls"
  9.     End If
  10.  
  11.  
  12.    Windows("rollifrp.xls").Activate
  13.    Range("A1").Select
  14.  
  15. ActiveWorkbook.SaveAs stDocName    ******ERRORS HERE SAYING DOCUMENT NOT SAVED******
  16.     ActiveWorkbook.Close
  17.  
  18.  
  19.  
  20. The full code for the macro is below:
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. Sub FXcurr()
  33. '
  34. ' FXcurr Macro
  35. ' Macro recorded 19/04/2006 by u415264
  36. '
  37.  
  38. '   Open Quantum download report
  39.  
  40.     Application.ScreenUpdating = False
  41.  
  42.     Dim stDocName As String
  43.     Dim AP As Range
  44.     Dim CurrYr As Range
  45.  
  46.     Application.ScreenUpdating = False
  47.  
  48.     Set AP = Worksheets("Index").Range("E4")
  49.     Set CurrYr = Worksheets("Index").Range("E6")
  50.  
  51.   ' rollifrp excel details only
  52.  
  53.     stDocName = "Q:\Reports\Financial Reporting\IFRS\Models\rollifrp.xls"
  54.  
  55.     Workbooks.Open stDocName
  56.  
  57.     Windows("rollifrp.xls").Activate
  58.     Cells.Select
  59.         With Selection
  60.         .HorizontalAlignment = xlCenter
  61.         .VerticalAlignment = xlCenter
  62.         .WrapText = True
  63.         .Orientation = 0
  64.         .AddIndent = False
  65.         .ShrinkToFit = False
  66.         .MergeCells = False
  67.     End With
  68.  
  69.     Rows("1:10").Select
  70.     Selection.Delete shift:=xlToUp
  71.  
  72.     Columns("F:F").Select
  73.     Selection.Delete shift:=xlToLeft
  74.  
  75.     Columns("G:G").Select
  76.     Selection.Delete shift:=xlToLeft
  77.  
  78.     Columns("H:H").Select
  79.     Selection.Delete shift:=xlToLeft
  80.  
  81.     Columns("L:L").Select
  82.     Selection.Delete shift:=xlToLeft
  83.  
  84.     Range("B2").Select
  85.     Selection.Cut
  86.     Range("B1").Select
  87.     ActiveSheet.Paste
  88.  
  89.     Range("G1").Select
  90.     Selection.Cut
  91.     Range("H1").Select
  92.     ActiveSheet.Paste
  93.  
  94.     Range("B1").Select
  95.     Selection.Copy
  96.     Range("I1").Select
  97.     ActiveSheet.Paste
  98.  
  99.     Range("I2:J2").Select
  100.     Selection.Cut
  101.     Range("J1").Select
  102.     ActiveSheet.Paste
  103.  
  104.     Range("K2").Select
  105.     Selection.Cut
  106.     Range("L1").Select
  107.     ActiveSheet.Paste
  108.  
  109.     Range("L2").Select
  110.     Selection.Cut
  111.     Range("M1").Select
  112.     ActiveSheet.Paste
  113.  
  114.      Rows("2:4").Select
  115.     Selection.Delete shift:=xlToUp
  116.  
  117.    ' ActiveSheet.Shapes("Picture -767").Select
  118.    ' Selection.Cut
  119.  
  120.  
  121.  
  122. '   Copy data to master file
  123.     Cells.Select
  124.     Selection.Copy
  125.     Windows("MASTER - FX Reconciliations Modelvista.xls").Activate
  126.     Sheets("rollifrp").Select
  127.     ActiveSheet.Paste
  128.  
  129. '   Reformat original file for saving in AP folders
  130.     Windows("rollifrp.xls").Activate
  131.     Columns("A:L").Select
  132.     Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
  133.         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
  134.     If AP.Value < 10 Then
  135.         stDocName = "Q:\Reports\Financial Reporting\IFRS\" & CurrYr & "\AP0" & AP.Value & "\04_Models\rollifrp AP0" & AP.Value & ".xls"
  136.     Else
  137.         stDocName = "Q:\Reports\Financial Reporting\IFRS\" & CurrYr & "\AP" & AP.Value & "\04_Models\rollifrp AP" & AP.Value & ".xls"
  138.     End If
  139.  
  140.  
  141.    Windows("rollifrp.xls").Activate
  142.    Range("A1").Select
  143.  
  144. ActiveWorkbook.SaveAs stDocName    ******ERRORS HERE SAYING DOCUMENT NOT SAVED******
  145.     ActiveWorkbook.Close
Apr 9 '14 #1
0 1236

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: somanyusernamesaretakenal | last post by:
What I am trying to achieve: Basically I have generated a report in access. This report needs to be updated using excel. (Updating the new data, not changing existing data) What I did was I...
0
by: liam_jones | last post by:
I'm very new to Python, well IronPython to precise, and have been having problems when using Excel. The problem I'm having is the closing of my Excel object. I'm able to successfully quit the...
0
Pakmarshal
by: Pakmarshal | last post by:
I developed a 64-bit Excel Addin. For testing I added it on a laptop (64-bit machine with 64-Windows7 Enterprise and 64-bit Office 2010) , its works fines i can call n use its functions. but when...
0
by: Terry Powers | last post by:
I have users with Ofc 2007 and Ofc 2010; all our databases are still in v2003. After opening any of our db's by a PC using Excel 2010, the reference list in the db is locked to Excel 14. Then any...
3
by: Vickie Easton | last post by:
I am SIMPLY trying to copy an entire row from one EXCEL workbook (hi-lite the entire row by clicking on the row # at the left side of page, then right-click and select copy), and insert a copy of it...
4
by: malka | last post by:
I would like to save an add-in build as VBA on Excel 2010. The function unhides all the hidden TABS on a Excel worksheet. Thanks
2
by: rahulwagh | last post by:
This macro is written in Excel 2010 which works perfectly on Microsoft XP but it fails on Windows 7 and 8. What macro does --- It gives 3 drop down options to user Select Month ----This is the...
0
by: scrapcode | last post by:
Hi everyone. I'm facing a problem with excel 2010 when using a function that worked fine in 2003. I'm using Environ(username) in the following function in module 1: Public Function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.