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

VB form to fill Excel Template

14
My project is moving along smoothly- I've gotten a lot of info from this forum. One thread that helped me understand what I was doing is here. But I have a question I can't find an answer to.

My form fields will populate an Excel workbook. No problems there. My question is how do I call it to enter the data into an Excel template I have already created?

The location of the template sits in my C drive- C:\DailyLogs\DailyLog.xlsx

Here's my code so far:

Expand|Select|Wrap|Line Numbers
  1.         ' Here we go. All the data in the form to an Excel sheet. Cross your fingers...
  2.         Dim oExcel As Object
  3.         Dim oBook As Object
  4.         Dim oSheet As Object
  5.  
  6.         'Start a new workbook in Excel- this isn't really what I need though, I need it to open a template and populate it.
  7.         oExcel = CreateObject("Excel.Application")
  8.         oBook = oExcel.Workbooks.Add
  9.  
  10.  
  11.         'Add data to cells of the first worksheet in the new workbook
  12.         oSheet = oBook.Worksheets(1)
  13.         oSheet.Range("A4").Value = Start1.Text
  14.         oSheet.Range("B4").Value = End1.Text
  15.         oSheet.Range("C4").Value = Time1.Text
  16.         oSheet.Range("D4").Value = CallType1.Text
  17.         oSheet.Range("E4").Value = Description1.Text
  18.         'etc....
  19.  
  20.  
  21.         'Save the Workbook and Quit Excel
  22.         oBook.SaveAs("C:\DailyLogs\DailyLog.xlsx")
  23.         oExcel.Quit()
  24.  
Any ideas?

Thanks,

Rob
Sep 19 '10 #1
1 3009
RobT
14
I got it!

Change line 10 of code to:

Expand|Select|Wrap|Line Numbers
  1. oBook = oExcel.Workbooks.Open("C:\DailyLogs\DailyLog.xlsx")
That worked perfectly.

I just thought I'd share my findings with others.
Sep 20 '10 #2

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

Similar topics

1
by: | last post by:
Hi all, I have some statictcle functions in C#, I am making some Excel templates, they are xls files. How to make my template using these functions? Before these functions are in Excel VB so...
3
by: Karen A Hodge | last post by:
I have a website that has an Excel template. The template contains 3 QueryTables. The template is located on the web server. I would like to refresh the data prior to the user opening the template...
0
by: sweeney_jones | last post by:
Hi, I am really struggling to figure out how to do this. I have a SQL view that contains 3 columns and upto 4000 rows. This is a series of question numbers and answers for a questionnaire....
5
by: steven | last post by:
Hello, I've created a Word-template for a letter. I've made some fields in the template (such as 'customer number', 'name', ...) as follows: insert field - DocVariabele with name 'customer...
2
by: Mr. California | last post by:
As a novice VBA programmer, I have a problem with a routine written as a click procedure from a form to open an Excel template, insert some information, print, and (ideally) return control back to...
2
by: Brent Bortnick | last post by:
Hello, Is it possible to send data from ASP and put it into a existing template? i don't want to create an excel document I only want to send one piece of information from ASP to the Exisiting...
2
by: Widge | last post by:
I have an Excel template that has to be populated with data each month. It has to be a this particular template because it has several functions embedded into it which are for a bespoke accounting...
1
by: chuch0117291 | last post by:
Hi, i have a form with the main details of a vendor and and contract description and a budget reference(PK). Within this form, i have a sub form which includes cost details for that specific vendor...
13
by: Peter | last post by:
VS2008 ans ASP.NET 3.5, Office 2003 What is the best way to run Excel Template from ASP.NET web page were the Excel is only installed on the client without any ActiveX? If so can someone point...
1
by: sydmil | last post by:
Hello, I am relatively new to VB6 and I was wondering if anyone could show me an example of a VB6 code to do the following: Open text file (which is a column of numbers) in excel - comma...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.