Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel VBA - Userform cmd problem

i have a user form that when the cmdbutton is clicked it opens anothe
workbook, inputs information in the next available space, then closes
without user seeing it open. The problem is when it closes, the "sav
as" window opens. is there coding i can use to automatically sav
changes and close the workbook without user seeing it close? here i
the code I have;

Private Sub CommandButtonOkay_Click()

Application.ScreenUpdating = False
Set SourceWB = Workbooks.Open("C:\greg\db.xls", _
False, True)


ActiveWorkbook.Sheets("Subdiv").Activate
Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtSubdivision.Value
ActiveCell.Offset(0, 1) = cboCity.Value
ActiveCell.Offset(0, 2) = txtZip.Value
ActiveCell.Offset(0, 3) = txtDirections.Value

SourceWB.Close True

ActiveWorkbook.Sheets("Costing").Activate
Range("D5").Select

Unload Me

End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel VBA - Userform cmd problem

Hi,

Try to save the workbook before closing and then close it withou
saving :

SourceWb.Save
SourceWB.Close False

P.S. : if the file's (opened) readonly, you'll get the Save As windo
again

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel VBA - Userform cmd problem

This line of code will close the workbook and save changes
automatically.

sourcewb.Close true


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel VBA - Userform cmd problem

I found out that the page was opening as "ready only"

so i changed the code from:
Set SourceWB = Workbooks.Open("C:\greg\db.xls", _
False, True)

to:
Set SourceWB = Workbooks.Open("C:\greg\db.xls")

and it works fine

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform problem? law Excel Discussion (Misc queries) 0 December 3rd 07 07:54 PM
userform problem TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 August 10th 06 04:43 AM
Userform problem (Listindex) jgmiddel Excel Discussion (Misc queries) 1 April 26th 06 01:34 PM
Problem using UserForm in Macro Terence Excel Programming 2 August 8th 03 01:12 PM
Problem using UserForm in Macro Bill Lunney Excel Programming 0 August 8th 03 08:54 AM


All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"