Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Code hides Excel sheet

Status
Not open for further replies.

MinnKota

Technical User
Nov 19, 2003
166
US
The following code Hides my worksheet! I don't want it to. Any clues why?

Set myWB = GetObject("c:\supplier.xls")
myWB.Sheets(1).Cells(3, 3) = Me!txtSupplier
myWB.Save
myWB.Application.Quit
Set myWB = Nothing
 
Hi,

What worksheet? Your code has no mention of any other worksheet than the one in the workbook that you are closing.

I suspect that it is this statement
Code:
myWB.Application.Quit
rather use
Code:
myWB.Close


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I only have one worksheet and it is actually entitled "Corrective Action" so the update code reads...

Set myWB = GetObject("c:\supplier.xls")
myWB.Sheets("Corrective Action").Cells(3, 3) = Me!txtSupplier
myWB.Save
myWB.close
Set myWB = Nothing

But it still hides the worksheet.
 
You are CLOSING the workbook that your worksheet is in! The worksheet is NOT hidden!

???

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Maybe I am not stating my problem clearly. Here is what happens. I run this code from Access and it inserts data into Excel. Then when I open the Excel file, I see nothing. Not even a blank worksheet. I have to go to Window and then click Unhide, then I see the worksheet and the data that was inserted.
 
try setting the Visible property of the APPLICATION TRUE
Code:
Set myWB = GetObject("c:\supplier.xls")
myWB.application.visible = true
myWB.Sheets("Corrective Action").Cells(3, 3) = Me!txtSupplier


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Have you tried this ?
Set myWB = GetObject("c:\supplier.xls")
myWB.Sheets(1).Cells(3, 3) = Me!txtSupplier
myWB.Sheets(1).Visible = xlSheetVisible
myWB.Save
myWB.Application.Quit
Set myWB = Nothing

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I thought that it might be a Window property that needed to be made visible, but that doesn't seem to work.
 
And something like this ?
Set myXL = CreateObject("Excel.Application")
myXL.Visible = True
Set myWB = myXL.Workbooks.Open("c:\supplier.xls")
myWB.Sheets(1).Cells(3, 3) = Me!txtSupplier
myWB.Save
myWB.Close
myXL.Quit
Set myWB = Nothing
Set myXL = Nothing

If the above code works, try to comment out the myXL.Visible line and let us know.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
it was the "Createobject" arguement that fixed things. I employed it after getting some advice in another thread, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top