Open Template In The Excel
Hi
How do I open the template from Excel using VB ?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
I Want To Open An Excel Template?
I know that if I have a command button in the following:
Code:
Private Sub Command2_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Activate
xlSheet.Application.Visible = True
Exit Sub
End Sub
Then I'll have a brand new Excel spreadsheet to transfer over data.
I have two questions.
1.) How can I pull up a template instead of a whole new document?
2.) How can I pull up a certain file instead of a new document?
Thanks for any help!
I appreciate it!
Sincerely
VB6, Open An Existing Excel Template For Editing From Code, Help
Dear all.
I need to open Excel templates from my VB app.
I am using the following code
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
xlApp.Visible = True
xlApp.Workbooks.Open MyFilename 'MyFilename is always an .xlt file
My problem is that Excel opens a new workbook file based on
the template 'MyFileName' and enumerates it with a 1.
So if the file I want to open is 'test.xlt' - Excel opens a new workbook called 'test1' based on the template.
Is there a way to just open the the template file for editing ?
Please please help
Many thanks
GT
Open Template
Hi everyone,
I'm trying to open a new document based on a template that I created from VB6.
My template is in the 'User Templates' folder for MS Word.
The only way I was able to do that is by creating a dummy doc based on my template, opening that doc, then opening AttachedTemplate, closing dummy doc. This kind of works, but there's got to be a shorter way to open the template.
Thanks for your help.
Open Template In VB6
Hi
I have a template named BLANK.xlt and what i am hoping to do, is, when i run my app, i would like my template to appear on screen everytime the app is opened, but, at the moment I am struggling on how i can do this.
When the app, and template is opened, the user will (hopefully) be able to add items into the cells of my template and once finished, save the edited template as their new document.
Can anyone please give me advice on how i can achieve this
Many many thanks in advance
Open Word Template
Is there a way to open a word template, make some changes...search and replace changes and then prompt the user to save the template as some other document?
Open Normal Template In Vb6
Ok...when you open visual basic editor in word will open you a NORMAL project himself. how do i open this NORMAL project in vb6 or where is this project for proggraming the normal template of word
TNX
Template Doesnt Open :(
I'm trying to write a template...Now I've followed the steps as described on:
http://www.fontstuff.com/vba/vbatut09c.htm and saved it all as document template. But if I open the document template, nothing happens (the vba form doesnt appear)..what am i doing wrong ? plz see attachment
How To Open Word Template?
I need to open a word template when a user hits the button. Then i need to add info to the document and save it as a different name.
Not sure how to specifically open a template.
Open As Template, Save As Doc
Hi there,
If I open a document as a template, et template.dot but then save it with a unique name, eg. word1.doc then how do I close all instances of word?
Cheers,
Padraic.
How To Open A Specific Word Template.
Hi, I'm trying to cut my programming teeth on a little side project at work.
Situation: I want to be able to call up a specific MS Word template from within an Access database. I modified some code that I found on this site and can at least get Word to open a blank document marked "read only" but not the specific document I want.
Here is the code so far:
Private Sub OpenWord()
Dim WordApp As Word.Application
Dim WordTemp As Word.Template
Dim STRTempName As String
STRTempName = "\fltntshr001ITG_CommonIT ServiceeFDNDealer AlertsDealer System Alert.dot"
Set WordApp = New Word.Application
Set WordTemp = WordApp.Documents.Open(STRTempName)
WordApp.Visible = True
End Sub
Thank you to the original author and thanks greatly for any help in advance to you all.
Open MS Word Document/template Through VB6
Hi all, I am writing the following code to open a word template
Code:Dim objWord As Word.Application
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open App.Path & "WordDotFile.dot", , , True, , "password"
The word template is password protected. This code does open the template file from VB6 but code macros of the template does not run. While I try to run the template directly, a vba form opens in the start up but when I open it through VB6 it does not evokes the form. Any guidance please...
Help - Need To Open And Read A Word Template From VB
Hi !!!
I have a Word Template file ( *.dot). which will have a text box and check box taking user input. i have to open that *.dot file and read the values given in the text box and check box and insert the values in to the db.how should i do it from VB.please help me in solving this problem.
Open A New Document Read-only Template
I am opening a new document on my own customized template from my vb program and everytime i close it it asks me if i want to save changes to the document and to the template.how do i make the template readonly so that it doesnt ask me if i want to save changes to it?
here's my code:
Dim doc As String
Dim temp As String
temp = App.Path & "Gael.dot"
doc = App.Path & "Doiciméad 1.doc"
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Add
wdApp.Visible = True
wdApp.ActiveDocument.AttachedTemplate = temp
wdApp.ActiveDocument.SaveAs FileName:=doc
Open Template If File Doesn't Exist
What I'm doing is I have a macro that opens a template, copies data over, and then does a 'save as' as the person's initials and closes that template.
What I would like to do is something like this:
In a specific folder, if there is an excel spreadsheet with that person's name, open that, copy data and save and close.
If that file does not exist, then use the template.
What I have so far does only the template, it doesn't look for the other excel file. Here is the code I have so far:
Code:
Location = "C:Engineer Progress Reports"
togetherness = Location & thefilename
Worksheets("Sheet1").Range("I4:M65536").Copy
Workbooks.Open ("P:projectdb emplate.xls")
Workbooks("template.xls").Activate
Worksheets("Sheet1").Activate
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("A1:E65532")
ActiveWorkbook.SaveAs Filename:=togetherness, FileFormat:=xlNormal
ActiveWorkbook.Close
ThisWorkbook.Activate
Thanks for the help.
Open A Word Template Save And Close
Hello,
I have some problem here figuring this out, , the plan is to open a template word file, write some data, SaveAs with new filename then close it. this code has some problem with it.
Set wdQE = New Word.Application
If UCase(cbxReportTemplate.Text) = "RIFFA" Then
wdQE.Documents.add (App.Path & " emplatesEnquiryRiffa.dot")
Else
wdQE.Documents.add (App.Path & " emplatesenquiry.dot")
End If
Call create_QEDoc(flvwsuppliers.TextMatrix(flvwsuppliers.Row, 1), flvwsuppliers.Row)
Dim oDoc As Document
Set oDoc = wdQE
oDoc.SaveAs "C:ProcEmailAttach" & txtRFname & ".doc"
oDoc.Saved = True
oDoc.Close
thanks in advance...
Open A MS-Word Template And Replace Some Text
I got some code of how to open MS word within VB6, that's ok, but my question is, once I had that doc or template which is what i want ( a template), open, what do I have to do to update the template with the info. retreived from a data-base?........
Open Word Template, Create New Document
How do i open a word template and create a new document from it?
There's like 20 parameters when opening a word.application
.documents.open(,,,,,,...... Mark P.
www.cafecartel.com
Providing Low Cost Powerful Point of Sale Solutions.
Template Open Events And Copying Worksheet Code
Hi all, 2 questions
1) What events are fired when a Template is opened? Is it possible to have some code execute when a template is opened? I'm looking to automatically run a macro every time someone opens a particular template file and figured the best way was through a workbook or worksheet event of some kind. Suggestions?
2) The template has some code in the worksheet that I need to copy to each new worksheet the macro creates. How do I access/copy the existing worksheet code to another worksheet? Or if I were to copy the worksheet itselt does the code come with it?
Thanks!
-Matt
Using An Excel Template
I'm having an issue using an Excel Template to compile a report with VB. My code opens a read-only excel file, and fills in the cells with the reporting information. It works perfectly -- the first time you run it. However, if the Sub is run a second time, and the user still has the original Excel sheet open, it does not work properly. What happens in this case is that the template will open a second time, but since the first file is still open, the cells on this sheet are changed, and the newly opened template is left blank. Here is my code:
Private Sub cmdSubmit_Click()
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
xlApp.Workbooks.Open FileName:="U:Test.xls"
xlApp.Visible = True
'Code to Change Cells Here'
End Sub
I think what I'm missing is a command after I change the cells that "unlinks" the VB app from the excel file.
Any Ideas?
Run An Excel Template
What I'm trying to do should be so easy but I can't get it to work
I have written a simple VB program before that involved pressing a button and it would delete and copy a file and then run an .exe file.
What I need now is to run an Excel template (.xlt) when a button is pressed. I've tried adapting the previous program but the Shell command doesnt work with an .xlt file.
I could set the path for Excel and get the appropriate temple to run but cannot guarantee Excel will be in the same path on every PC the software runs on
Excel Template
i have a vb program that needs to use a template from excel...when i compile can i 'add' this template along? ( compile everything into one..)
Using Template Excel From VB
Hi
I building someone template in the Excel and want use, I have 4 (four) templates and the user choice the report that He want , and I open the Excel template in conformoty with the choices the user.
How do It ?
Excel Template Files
Why are Excel Template (.xlt) files smaller than Excel (.xls) files? What do I lose by saving documents as Excel Templates (i.e. object model, formatting...)?
Hiding An Excel Template?
I have an excel template that opens a new worksheet and populates it with a load of data from a particular database. This is working fine but I don't want the user to be able to switch to the template worksheet so I'd like it to be invisible.
Is there any way of doing this (or something similar?).
Thanks in advance,
Duncan
Template Excel File
Heya...
I was just wondering if I make a template excel file is it possible to have a vb program grab that template file make a new excel sheet based on that template file?
Thanks ppl..
Printing Excel Template
i wanted to do some printing of data on an excel template...
i will extract the number of records that need to be print out..
i will be using objRS.movenext...
do i need to state the condition EOF or BOF?
Using Existing Excel Template
Hello I have documentation that teaches you how to make my VB program open up Excel and enter data in the cells, but I want to use an existing template and have the cells 'fill up' with the data from the program. If anyone knows please help me and thank you in advance.
VB && Excel Template Formatting
I have a Excel Template that I am trying to modify with commands like this:
obWorkSheet.Cells(10, "C").Value = txtCustomerName.text
That works great. The problem is I am loosing the formatting when I save the excel file.
obExcelApp.Save ("C:INVOICE.XLS")
By loosing formatting I mean, the row heights are set back to default, and I can see the grid lines that were turned off in the original template.
How can I preserve my formatting settings????
Help??
Jeremy
Importing .txt File Into Excel Template
I have a .txt file that I need to import into and Excel template using a VBA macro. The template will always be the same as well as the format of the .txt file. What will change is the amount of data that is in the .txt file. Can anyone help with this???
Excel Template From Access Db Problem...
I am currently writing a package that will print the clients a sheet from Excel, that has information in it that has been dumped from a database. However, that part is relatively easy to do. However, the difficult part, and the part where I am having problems with is that the Excel worksheet is set out as follows:
Row 1: Blank
Row 2: Blank
Row 3: Headers
Row 4: Blank
Rows 5 - 13: Data
Row 14: Blank
Row 15: Blank
Rows 16 - 24: Data
The rows with data in, all contain data that is extracted from an Access db, using a sql query.
My problem is:
How do I have one single query, that populates this Excel template, but puts the data in the pre-formatted places. In other words, I need to be able to jump 2 rows (from row 14 to row 16)?
I would be very grateful if anyone has a solution!
Modifying Word Template From Excel
Hey everyone, kinda stuck here if anyone can lend a hand
The template opens but after that i get errors saying my selection is wrong.
Code:
Sub MakeWordDocument()
Dim oWord As Object
Set oWord = CreateObject("word.Application")
oWord.Visible = True ' <-- ** Optional **
With oWord
.Documents.Add Template:= _
ThisWorkbook.Path & "" & "AndesTemplate.dot" _
, NewTemplate:=False, DocumentType:=0
End With
With .Selection
.MoveDown Unit:=wdLine, Count:=6
.TypeText Text:="HEre"
End With
End Sub
Can't Protect Code In An Excel Template
I know how to protect a VB Project by opening the Properties window, etc, etc.
That works when I am editing the original Excel template file - the .xlt file I created.
However, when I create a file based on the template (File-New, then choose the template), the code is unprotected and viewable.
How can I protect my project so that it's unviewable in the .xlt template file AND any .xls workbook files that are created from it?
Thanks in advance.
Incrementing Numbers In Excel Template
I would like to be able to automatically increment numbers when opening a workbook based on an excel template. example when opening a workbook number 75 auto. pops up in a specific cell. only when i save the workbook will the next workbook opened contain the number 76. i would also like to be able to automatically log these numbers into a database type format either in excel or access
thanks
christian
Insert Data Into Excel Template From A Recordset.
Hi Guys,
I have an existing Excel file with several worksheets. Each worksheet is a template to a certain report. I have my records in a database, that I would like is to copy to these excel templates and save it or save as.
I tried QueryExcecute before, and it worked better than loops. Can I still apply that method considering that my records will have to fit to the template that I opened?
I'm searching for threads on how to open an existing excel file and apply changes to it and perform save or save as. If you know one please direct me.
Thanks a lot.
Export Access Data To Excel Template Using ASP
Instead of creating a new excel sheet design, can i use a template which is in *.xlt format and get the data from the access database and insert it into the template ???
And another problem that i face is everytime when i try to get a record from the database, it will convert all the value into the nearest decimal point.
eg the record in my database is 8.00 and it will convert it to 8.
How can i display exactly what ever that is in my database in to the excel sheet ??
Exporting Access2003 Report To Excel Template.
I have an excel template that consists of just the column headers and want to populate the rows with data from an access report. right now I am using code to export the qry i use for the report but it just creates a new sheet instead of putting it on the template sheet. anyone help?
Opening An Excel Workbook From A Template In Access VBA
Hi there.....this may be a doosie but i was wondering if anyone knew how to go about opening an excel document derived from an excel template through VBA code in my Access form. I understand whenevr you open a template a new workbook is created but have no idea how to handle the code.
Any insight would be helpful.
Thanks
Setting Save-As Hint In Excel Template
Hi All,
I've recently put together an excel template for my mum that organises the input of some data. one of the things it does is present a list of dates of mondays, one of which is selected, and that then generates the calendar for that week. once the data are filled in she wants to save the instance of the template as a standard excel document. the default behaviour seems to be that the template name is taken and a number appended. I'd like to use the template name and append the start date of the calendar (the one selected from the popup box) and then have that as the default filename hint in the save-as dialogue box. how do I set this hint?
i can't find this method anywhere, perhaps i'm using the wrong search terms... any suggestions?
best,
conejito.
Need Macro To Launch Excel Template From Word
VBA neophyte here.
I need a macro to launch an Excel template from within Word. I have managed to glean the code below from off the web to launch the app but I do not know how get it to open a workbook.
Many thanks in advance,
Wbaker
Sub Excel()
Dim MyAppID
MyAppID = Shell("C:Program FilesMicrosoft OfficeOFFICE11excel.exe", vbMaximizedFocus)
AppActivate MyAppID
End Sub
Opening An Excel Template That Has Data Tracking
I am fairly new to VB 6 I am creating a user interface that hopefully will provide links to various documents. I have had problems writing the right code to open files from both excel and word. The code runs but the document is not visible. The documents that I want to be available would be edited by the user and then printed off. Can you help. This question is similar to othes posted but due to slight variances I am confused by the coding for procedures/functions I do not need to iput.
Thanks in anticipation of your help
Anita
Excel Template Loading VERY Slowly Via Automation
We are having an issue with our servers taking large amounts of time (from 1 minute to 1 HOUR) to open an Excel template via Automation. We have narrowed the issue down to the use of combo boxes within the template. If we remove all 38 combo boxes, the template opens in less than 1 second. As we add combo boxes (VB objects not Form objects) back to the template, the load time grows again.
We have also tried a test where we use a blank workbook and create the combo boxes on the fly via code (OLEObjects.Add) but it takes the same amount of time (1 minute to 1 hour) to do so.
We have 6 servers, 5 of which are Win 2K. The 6th server is Win 2K3. All have Office 2000 with SP3 installed. The 6th server is much faster than the others at loading the template but still takes a minute.
Our developer machines (Windows XP) all open the template instantaneously via Automation:
Set Xl = CreateObject("Excel.Application")
Set XlApp = Xl.Application
XlApp.Workbooks.Open FileName:=sTemplate
NOTE: We can open the template directly on the server and it is instantaneous. However, via Automation, it takes the delayed amount of time.
We have confirmed all machines (including developer's machines) have the same version of FM20.DLL on them.
Does anyone have any ideas what could be causing this and how we can resolve the issue? Clearly, we cannot afford for the server to be choking along for this duration of time as the opens the template during our reporting process (Visual Basic 6.0 app, using Excel for output target)
Blocking Template After Exporting From Access 2002 To A Word Template
I am having some difficulty determining the appropriate code for stopping a template from popping up after I close the document to which my Access data has been transferred to. My VB code automatically saves the document, but when I quit Word, my original template pops up. Whatever code I insert into VBE doesn't seem to stop it. I hope someone can help me.... Here's the relevant portion of the code below:
'Creates a Word instance to use for the 8D form. Uses the existing
'Word instance if there is one; otherwise, creates a new instance.
Set objWord = GetObject(, "Word.Application")
If Err.Number = 429 Then
'Word isn't running; creating a Word object.
Set objWord = CreateObject("Word.Application")
Err.Clear
End If
On Error GoTo Command126_ClickError
strDocsPath = "V:QCProblem Cases" & ""
strSaveName = "BWA CAR No. " & Me![Customer Tracking Number] & ".doc"
strSaveNamePath = strDocsPath & strSaveName
strTemplatePath = "V:QCProblem Cases" & ""
strWordTemplate = strTemplatePath & "8Dform.dot"
'Check for existence of template in template folder,
'and exit if not found
strTestFile = Nz(Dir(strWordTemplate))
If strTestFile = "" Then
MsgBox strWordTemplate & " template not found; can't create 8D form"
Exit Sub
End If
Set objDocs = objWord.Documents
objDocs.Add strWordTemplate
.
.( I have removed the section which relates fields between Access and the template...there's nothing that controls opening and closing of the document)
.
.
With objWord
.Visible = True
.Selection.WholeStory
.Selection.Fields.Update
Debug.Print "Going to save as " & strSaveName
.ActiveDocument.SaveAs strSaveName
.Activate
.Selection.EndKey Unit:=wdStory
End With
Command126_ClickExit:
Exit Sub
Command126_ClickError:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume Command126_ClickExit
End Sub
I would appreciate if I receive a reply ASAP (job-related!!)
How To Paste On A Word Template Without Loosing The Formatting Of The Template?
I'm new on VB please help me!
I have to fill some special word template with informations caming from an access DB.
Here the code I'm using now.
Private Sub SearchAndReplaceOnce(monDocWord As Word.Document, strTagARemplacer As String)
Dim maPlage As Variant
Set maPlage = monDocWord.Content
With maPlage.Find
.ClearFormatting
.Execute FindText:=strTagARemplacer
If .found = True Then maPlage.Paste
End With
End Sub
All this code is working but the method Paste is replacing also the formatting that I have pre-defined on the word template.
How can I do to avoid this problem?
Thanks
Sending Excel Template Data To An Access Database
I am working with Excel 2002 and I have developed a template for data input and then used the template wizard to dump the data into an access database. I am using “record macro” for users to submit the information. One of the functions I want the macro to record is to save the file. When I do this manually, a pop-up box appears called “template file – save to database” and it says “the contents of this workbook have not been saved as a record in the database. What would you like to do? create a new record; continue without updating “ I want the program to choose “create a new record”. I can do this manually, but when I go to the recorded macro, it only has: Activeworkbook.save
And when I run the macro, it does not transfer the data into my database, so it looks like it defaults to “continue without updating”
I would like to add the code to choose “create a new record” in that pop-up box, but have no coding experience. Can anyone help me? Thanks.
Word Object To Save Template As A Template.
I use a word object to open a template and resave it to template.
The reason I'm opening the template is that I want to run a macro that fills the template with data from bookmarks.
I use this code:
Code:
Dim objWordApp As Object
Set objWordApp = CreateObject("Word.Application")
objWordApp.Documents.Add Template:=TemplatePath, NewTemplate:=True
objWordApp.ActiveDocument.LoadMe sConn, FunctionId, sFunctionType, SupplierId
objWordApp.ActiveDocument.SaveAs FileName:=WorkPath & FileName
objWordApp.ActiveDocument.Close SaveChanges:=wdSaveChanges
But when opening the new template I get this annoying reference to the old template. The old macros doesn't save in the new template.
When running save as in word on a template the macros are transferred to the new file without referencing to the old macro.
How do you do this in VB?
|