VBAPrincess
Programmer
Our company is upgrading all user computers to Windows 10 with Office 2016. I have an Access database (mdb) that has code to open an Excel template (xltm), populate data, and then allow the user to save the file. The code worked fine on Windows 7 with Office 2010. Now, when the code opens the template, Excel opens 22 blank windows along with the template. It seems to open as many windows as it can until it finally crashes. I have stepped through the code and it will open the template (line 3), but opens the other windows as soon as the code inserts a value into one of the cells on the worksheet (line 10). The code actually won't let me step through the insertion of the values, but rather just runs to the end once I run that first line that enters data in that first cell.
Any idea what could be happening? I have decompiled/compiled thinking perhaps something was corrupted. It works the same. I tested again using Win7/Ofc2010 just to confirm and it works just fine in that environment.
Thanks in advance!
Diana
Any idea what could be happening? I have decompiled/compiled thinking perhaps something was corrupted. It works the same. I tested again using Win7/Ofc2010 just to confirm and it works just fine in that environment.
Code:
1 sTemplate = DBPath & "StorageTemplates\StorageFirstRaterv8.xltm"
2 Set oExcel = CreateObject("Excel.Application")
3 Set oWB = oExcel.Workbooks.Open(sTemplate)
4 Set oWS = oWB.Worksheets("Rater")
5 blnOldRate = False
6 sql = "SELECT [Main: Policy].[Policy Increment Key], [Main: Policy].[Name Insured],[Main: Policy].[Policy Number], " & _
"[Main: Policy].[date effective] AS EffDate, IIf(InStr([status],'renew'),'Renewal','New') AS BizType, " & _
"[Main: Policy].QuoteDate, Locations.[Building Street], Locations.[Building City], Locations.[Building State], Locations.[Building Zip] " & _
"FROM [Main: Policy] INNER JOIN Locations ON [Main: Policy].[Policy Increment Key] = Locations.[Policy Increment Key] " & _
"WHERE ((([Main: Policy].[Policy Increment Key]) = " & lngCodeKey & ")) ORDER BY Locations.LocationID"
7 Set db = CurrentDb
8 Set rs = db.OpenRecordset(sql)
9 If Not rs.EOF Then
10 oWS.Range("E7") = rs.Fields("Name Insured")
11 oWS.Range("E9") = rs.Fields("Policy Number")
12 oWS.Range("E13") = rs.Fields("Building Street")
13 oWS.Range("E15") = rs.Fields("Building City")
14 oWS.Range("E17") = rs.Fields("Building State")
15 oWS.Range("K17") = rs.Fields("Building Zip")
16 oWS.Range("E11") = rs.Fields("EffDate")
17 oWS.Range("K11") = "Bound Policy"
18 End If
Thanks in advance!
Diana