473,385 Members | 1,907 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,385 software developers and data experts.

Multiple Excel docs opened but i need only one of them closed

i have a code that get, set, save and close an excel document.
my problem is when i have other excel open, all of them closes

here is my current code which is not mine, i copied it from some one else.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  
  3.     Dim xlApp As Excel.Application
  4.     Dim xlbook As Excel.Workbook
  5.     Dim xlsheet As Excel.Worksheet
  6.  
  7.     Set xlbook = GetObject("D:\Templates\MayBank.xls")
  8.     Set xlApp = xlbook.Parent
  9.  
  10.  
  11.     xlApp.Visible = False
  12.     xlApp.Windows("MayBank.XLS").Visible = True
  13.     Set xlsheet = xlbook.Sheets("Sheet1")
  14.  
  15.  
  16.     xlsheet.Cells(1, 9) = Text1.Text
  17.     xlsheet.Cells(3, 2) = cboCompany.Text
  18.     xlsheet.Cells(3, 9) = Text2.Text
  19.     Label1 = xlsheet.Cells(5, 1)
  20.  
  21.     xlbook.Application.DisplayAlerts = False
  22.     xlbook.SaveAs "D:\Templates\MayBank.xls", FileFormat:=xlExcel8, AccessMode:=xlExclusive, ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
  23.     xlbook.Close
Nov 21 '14 #1
2 1098
nevermind, i got what i wanted to work..
Nov 21 '14 #2
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

Can you post how you solved the problem in case someone else has the same issue?
Nov 21 '14 #3

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

Similar topics

0
by: Eliezer Figueroa | last post by:
Managing Multiple Excel incoming files? I have this situation. I have a client which have several locations they work primary with excel forms and they are thinking in doing reports with them....
1
by: Andy Britcliffe | last post by:
Hi I'm faced with the situation where I could have a single physical file that could contain multiplie XML documents e.g file.txt contains the following: <?xml version="1.0"...
2
by: Jen | last post by:
Trying to take one table in access and split it into multiple excel files(using an excel template); and then email based on email addresses in Table2; Of course, I would like to do all of this...
5
by: cnathaide | last post by:
I am trying to control an existing running process from C#. More specifically, I am trying to control an existing workbook that is open in memory. I use the following code using...
4
by: Phoebe. | last post by:
Hi, Good Day! Reading 1 excel file into a dataset is fine. How can I read multiple excel with the same data structure into 1 dataset? How can I append those data? Can someone help? Thanks in...
2
by: krissh | last post by:
I know How Excel sheet in php .But wat i want is how to create Multiple sheets in Excel . This is the code for creating one excel sheet <?php header('Content-type:application/ms-xls'); ...
2
by: ciaran.hudson | last post by:
Hi I have multiple excel files of the same format in a directory. They are called book1.xls, book2.xls, book3.xls and so on. What is the easiest way to import the tab named sheet1 from each of...
3
by: stephen | last post by:
Hi, I have 5 excel files and they have multiple sheets. I have to read (say sheet 3) of each of the 5 excel files and consolidate them into one. what's the best way to achieve this. if someone...
0
by: crazycat | last post by:
hello im face a problem with link multiple excel file with one access database for more information : 1- i have 27 excel file to employee that contain account number 2- this 27 excel file...
13
by: WU JU | last post by:
Hi. I have thousands of excel files in one directory. I want to build up the Access table from excel files. Each excel file has one worksheet, but I don't need every column and low of the...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.