Excel file becomes hidden
Excel file becomes hidden
(OP)
Hi Folks -
I have a VBA program that I am having trouble with. It creates an Excel spreadsheet by copying an old one, then changes cell values, then saves and closes it. The problem is, when I open the worksheet in Excel it is HIDDEN. I have to go Window/UnHide and pick the file. What gives? Here is the code I use:
Set MasterObj = GetObject("M:\Master.xls")
MasterObj.SaveAs "J:\NewFile.xls"
MasterObj.Close
Set NewObj = GetObject("J:\NewFile.xls")
NewObj.Worksheets(1).Range("K13").Value = 3
NewObj.Save
NewObj.Close
I have a VBA program that I am having trouble with. It creates an Excel spreadsheet by copying an old one, then changes cell values, then saves and closes it. The problem is, when I open the worksheet in Excel it is HIDDEN. I have to go Window/UnHide and pick the file. What gives? Here is the code I use:
Set MasterObj = GetObject("M:\Master.xls")
MasterObj.SaveAs "J:\NewFile.xls"
MasterObj.Close
Set NewObj = GetObject("J:\NewFile.xls")
NewObj.Worksheets(1).Range("K13").Value = 3
NewObj.Save
NewObj.Close





RE: Excel file becomes hidden
Sub Test()
Dim wb As Workbook
Dim ws As Worksheet
Dim sSource As String
Dim sDestination As String
'Copy File
sSource = "M:\Master.xls"
sDestination = "J:\NewFile.xls"
FileCopy sSource, sDestination
'Update New File
Set wb = Workbooks.Open(sDestination)
Set ws = wb.Worksheets(1)
ws.Range("K13").Value = 3
wb.Close SaveChanges:=True
'Clean Up
Set ws = Nothing
Set wb = Nothing
End Sub
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: Excel file becomes hidden
But...
My VB application is compiled to a standalone exe program. It solicits design parameters, allows adjustments and what-ifs, creates an AutoCAD dxf file, answers that get cut-and-pasted into master drawings AND creates a bill-of-material from a master Excel file. The copy part works, it puts data into the appropriate cells and when I quit the program, the Excel worksheet is there. Only, when I open the worksheet in Excel it is hidden !! Weird.
RE: Excel file becomes hidden
Dim wb As Object
Dim ws As Object
I have developed several applications that utilize Excel, but have never come across this situation before. I can only assume that the procedure you are using is somewhat flawed. If you can provide some additional details, I am sure that the problem can be fixed.
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.