Size Limit for Combobox Recordset
Hello,
I am currently creating a VBA Userform in Word and have hit a bit of a wall.
On the userform I have a combobox that I am trying to populate using an
Excel recordset. The recordset currently has 700 records however when I run
the program the combobox is only loaded with first 500. Is there a way to
change this and have all 700 records load?
Z Tag: how to play a sound when Word starts Tag: 82159
Identify a Different Template for AutoText Entry
Dear All,
I have a sub that works. It looks to the normal.dot. to Find an autotext
entry. I'd like to be able to tell it to look for a specific template
elsewhere -- not necessarily one of the default template directories. A
pointer in the direction of how to declare a different template as a
variable would be appreciated. And, does the templated have to be "open" to
be able to access an autotext entry??
Code for macro follows.
Thnaks
Ridge (in New Joisey)
Public Sub DocNameAndPath()
' a macro to use the standard Word autotext entry
' "Filename and Path" stored in the normal template
' to add the filename and path to the end of a document
Dim myRange As Range
Dim oDoc As Object
Set oDoc = ActiveDocument
Set myRange = oDoc.Range
myRange.Collapse (wdCollapseEnd)
myRange.InsertAfter (vbCrLf)
myRange.Font.Name = "arial"
myRange.Font.Size = 8
myRange.Font.Italic = False
myRange.Font.Bold = False
myRange.Paragraphs.Alignment = (wdAlignParagraphLeft)
NormalTemplate.AutoTextEntries("Filename and Path").Insert
Where:=myRange, RichText:=True
Set myRange = oDoc.Range
myRange.Collapse (wdCollapseStart)
myRange.Select
End Sub Tag: how to play a sound when Word starts Tag: 82158
HOW CAN OTHER PEOPLE OPEN MY E-MAIL ATTACHMENTS?
When I sent an attachment only half of the people on my list can open it. Is
there an alternate way to send attachments so other systems can open them? Tag: how to play a sound when Word starts Tag: 82157
Problems with Template
I am trying to take a form (which has been saved as a template and uses
checkboxes and textboxes from the forms toolbar) and put it in a folder on
our Network so different users can access the form. I would prefer that if
one user is in the form, it will not allow other users to make changes until
the form is saved and closed. The form has various MAIN group headers with a
checkbox and my programming allows the user to check this main group header
and it will check everything under that group (I did this with Macro's).
When I email the form to other users for testing, it opens it with the title
Document1 and will not execute the code (The template is saved as
ProjectTemplate and I have a document that is saved as ProjectDocument).
I need to know how I can put this form in a network folder so that when
myself or any user opens it, it will have the changes made from the previous
user. Do I need to put the template and the document in the folder? Any
help is greatly appreciated. Another side note, when I open the template or
the document, it asks me if I want to enable macros and I click yes. Also, I
am on an XP operating system with a newer version of Word and some of the
other people I have emailed the document to for testing are still on '98
machines. Could this be part of the problem? Tag: how to play a sound when Word starts Tag: 82146
Pictures are cut when they are inserted in the word document.
Hello,
I have a problem in programming word VBA.
I want to insert graphs from the clipboard into a word document at all the
positions where '[[Graph]]' is written. The document contains tables and has
a layout with two text columns. At some positions in the document, a strange
thing happens when I try to paste the graph there: I can see only the lower
fourth of the picture when I format it "in line with text", but if I switch
to the format "before text", than the whole graph is visible.
Can anybody help me?
Thanks
Markus Tag: how to play a sound when Word starts Tag: 82139
Adding complex cross-reference
Hi,
in my documents I need to add quite a lot of cross-references. They also
need to be of the type which will say " 3.4.13 How to kill a hamster, p.
49".
Currently the only way for me to do this is to use my keyboard shortcut to
bring up the corss reference window, select the paragraph and then use the
dropdown menu 3 times to add the correct reference fields.
This is very manual process, but I have not been able to automate it any
more. I would think that this would be a standard requirement when writing
long and complex documents.
Does anybody have any suggestions how it could be made easier?
Thanks,
R. Tag: how to play a sound when Word starts Tag: 82136
Word fields
Hi There
I would like to set up a report template in Word. Within this template I
would like to create a bespoke dialogue box that asks a series of questions
which, when answered, will populate the relevant fields within the report
eg:
What is the Client Company's name?
What is your business division/address? (for this question I would like
pre-determined options ie drop-down menu)
I am not familiar with 'code' so, if this is required, please can you start
from the begining!!
Many thanks Tag: how to play a sound when Word starts Tag: 82135
Reordering a document
Hi,
The main problem at hand is that I need to create a new document that
contains the current documents data, just in a different page order.
I can copy the needed page and paste it into a new document, but i cannot
find a way to paste it at the end of the document.
Please help:(
Thanks Tag: how to play a sound when Word starts Tag: 82134
Call an addin command from a macro?
I have a commercial addin that creates bibliographies (Thomson's EndNote). It
loads a .WLL and adds a group of commands under Tools. It has a .DOT file
that provides a toolbar with the same commands.
Can I call one of these commands from a macro? I tried selecting the command
while recording a macro, but nothing gets recorded.
The commands do not appear under the Commands tab of the Customize dialog.
The toolbar button has an identifying name. Can I use that somehow?
Thanks for any leads. Tag: how to play a sound when Word starts Tag: 82120
Mailmerge from excel
I am trying to create a mailmerge in excel with the click of a button. When
the button is clicked it opens word sucessfully.
Sub OpenWord()
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.application")
Set wdDoc = wdApp.Documents.Open _
(Filename:="C:\Documents and Settings\steve\My
Documents\MyTestDoc.doc")
wdDoc.Close savechanges:=False
Set wdDoc = Nothing
wdApp.Quit
Set wdApp = Nothing
End Sub
The code I have placed in Word gives me an error (Ambiguous selection) at
the second line .Destination=wdsendToPrinter.
Private Sub Document_Open()
With ActiveDocument.mailmerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
I'm making the assumption (new to VBA in excel and word) that the document
is not
active but the spreadsheet is and therefore will not print. Not sure how to
solve this.
If anyone can give me any assistance it would be very much appreciated.
Steve Walker Tag: how to play a sound when Word starts Tag: 82111
Shape
I want to remove all the Shapes that are in the top of InlineShapes, and ONLY
those.
I already have a code that select the InLineShape and format them.
What I can't do, is Delete all the Shapes in the select Paragraph, or in the
InlineShapes.
Can you help me with this? Tag: how to play a sound when Word starts Tag: 82110
VBA Class
Hello,
I'm teaching a 2 day Intro to VBA for MS Word class and was wondering if
anyone had a recommendation for a training guide, reference guide, quick ref
guides etc. that I can purchase and use for my students. I've already
checked Amazon and there are a few things, but wanted to check with you all.
Thanks Tag: how to play a sound when Word starts Tag: 82106
InlineShape position in document
I need to know how I can get from VBScript position of InlineShape object in
document... I mean relative position on page (Horizontal and vertical offset
from any corner of page...
Thanks for aswers, sorry for bad english... Tag: how to play a sound when Word starts Tag: 82105
Converting word doc with macro to html
I have a word doc that has a series of tasks and then a check box after each
question for the user to 'check' when they have performed the task.
At the top of the page is a button with a macro attached that simply
'unchecks' all the checkboxes when pressed.
What I really want to do is convert it to html so I can have it on a website
(i know I could put the word doc there but html loads quicker), but when I
'save as web page' it loses the check boxes and macro.
Anyone know how I could create the html?
Thanks. Tag: how to play a sound when Word starts Tag: 82103
Setting font back to default in macro??
I have a macro that based on certain conditions changes the font to hidden
and changes the color.
Dim fHidden As New Font
'Setup hidden font for marker
fHidden.Hidden = True
fHidden.Bold = True
fHidden.Color = wdColorOrange
a.Insert(Where:=Selection.Range, RichText:=True).Font = fHidden
The issue is that after this is done the font seems to remain set to these
settings when another macro inserts text and doesn't specify a font setting.
a.Insert Where:=Selection.Range, RichText:=True
How can I easily get the font cleared back to the default settings? Tag: how to play a sound when Word starts Tag: 82094
Get line width from a range object in Word 2003 VBA
Hello,
I have a problem in programming word VBA.
I want to insert graphs from the cliboard into a word document at all the
positions where '[[Graph]]' is written. To setup the graph in the other
program (MATLAB), I need the width of the line of the text column (the
document has more than one column) the graph is pasted in. I locate the range
objects with range.Find.execute "[[Graph]]". How can I get the width of the
text column of this range object?
Best regards
Markus Tag: how to play a sound when Word starts Tag: 82086
Excel to VB
Hi
I have a simple spreadsheet that needs to be updated by more than 10 people
Simultaneously. But this is not possible as the spreadsheet becomes locked
when one person has it open.
My first idea was to create a front end with a Microsoft database to store
all records. But they do not have Microsft Access on their server.
Now I am thinking of creating a vb front end application. This will include
a few input boxes and an update command button which, will update the excel
sheet with the latest data.
I am 19 and new to programming. I really need to know what is the best way
to go about this and few tips on how to code it.
Many thanks Tag: how to play a sound when Word starts Tag: 82080
Selecting a text block
Hi,
I would like to write a simple macro what would activate "block select"
(Ctrl+Shift+F8) and leave the block select" active until an appropriate
action concerning the selected bloc is taking.
I find that it is not possible to simply record the Ctrl+shift+F8
sequence. Can someone give me pointers?
Thanks
--
John Doue Tag: how to play a sound when Word starts Tag: 82070
Shapes
I need to set the properties of a textbox programatically to anchor to the
top of a line.
Is it possible to programatically define the line that the textbox should be
anchored to.
Thanks
Mark Baird Tag: how to play a sound when Word starts Tag: 82062
Please provide example of WordML <specVanish/> element.
I am trying to suppress text in a WordML document that must remain in the
document for future reference. The specVanish element appears to be an
answer, however, I have not had any success with its use. Looking for a
working example.
Thanks Tag: how to play a sound when Word starts Tag: 82054
Format to display hh:mm:ss
hello everyone
I have the following line of code
.Caption = Format((lngWords \ 90), "##,##0") & " minutes of Text - Microsoft
Word"
I want to convert the lngWords to hh:mm:ss
my formula would be
(((lngWords / 1.5) / 60) / 60) / 24
Any kind of help would be appreciated
thanx
ahmed Tag: how to play a sound when Word starts Tag: 82048
Enter key does not work in User Form
I have created a UserForm in word Office XP. It works great, except when you
press the enter key while typing info. in the text box. It tabs to the next
text box.
The user will need to be able to use the Enter Key to move to the next line
or theis form is usless to me.
Please keep in mind that I am a novice in it took me four days to figure out
how to make the Form in the first place.
Thank U in advance Tag: how to play a sound when Word starts Tag: 82047
Links
Hi
If i write down the word "Gunnar" in a place in a Worddocument
i want Word to update 1 other place in the document with
just that Word.
Are there any one who know how i do that??
Gunnar Tag: how to play a sound when Word starts Tag: 82044
Active X names keep changing
I am creating a document for which I have several checkboxes and text boxes.
While working with these the names keep changing or a 1 is added. I am using
Word 2003 with all the updates. Is there a fix for this???
--
Thanks,
Darrin Tag: how to play a sound when Word starts Tag: 82040
FAQ - Frequently Asked Questions - vba - please read before posting - unofficial March posting
FAQ = Frequently Asked Questions - brief - vba - unofficial
This FAQ is posted weekly.- more or less
Please save us all some time by reading it before posting to the
news group.
This newsgroup is about VBA - Visual Basic for Applications -
which is the programming language for Word 97-2003 (macros).
There is a longer FAQ with more questions and links that is
regularly posted in the non-VBA Word newsgroups. You may want
to check that out as well.
--- BEFORE POSTING ANYTHING PLEASE READ THESE ---
http://www.mvps.org/word/FindHelp/Posting.htm
http://www.dts-l.org/goodpost.htm
Reading these articles will help you get a quick and meaningful
response to your question rather than just more questions for you.
It may keep your message from being screened or bounced.
A few basics, though:
(1) Be nice; everyone answering questions here is a volunteer.
(2) Post a question in only one newsgroup generally. If you
_have to_ post in more than one, post a _single_ message and
put both newsgroups in the header for that _single_ message.
(3) Do not attach anything to a message.
(4) The only really stupid question is the one you don't ask.
(5) Do not use your real email address unless you want spam.
(See bottom for sample.)
The reasons for the requests are spelled out on the web page.
A longer version of this FAQ is also on the Internet at
http://addbalance.com/word/index.htm
Newsgroup Archives:
http://groups.google.com/advanced_group_search
MVPs FAQ site:
http://word.mvps.org/FAQs/MacrosVBA.htm and
http://word.mvps.org/FAQs/Userforms.htm
To the extent there is any "official" FAQ, this is it.
---
Also, before posting, you may want to look at the following
questions to see if yours is among them.
---------- ---------- ---------- ---------- ---------- ----------
1. I see a macro in a newsgroup I would like to try. How
do I add it to my template?
http://addbalance.com/word/macrosfromnewsgroup.htm or
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm
http://www.gmayor.com/installing_macro.htm
2. What are some good books for me to read about Word?
http://addbalance.com/word/wordbooks.htm and
http://www.mvps.org/word/Tutorials/BookRecommendations.htm
3. How can I run a macro automatically when a document opens,
closes, is created?
http://www.mvps.org/word/FAQs/MacrosVBA/DocumentEvents.htm
4. How can I distribute or backup macros / customizations?
http://word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm
http://addbalance.com/word/movetotemplate.htm
5. What is an MVP?
http://www.mvps.org/word/AboutMVPs/index.html and
http://addbalance.com/word/mvp.htm
6. I need to make a form to...
Userforms are custom dialog boxes written using vba.
If you want a fill-in-the-blanks form you want what Word
calls an online form. Look in Word's help for that,
and for more info on online forms follow the links at:
http://addbalance.com/word/wordwebresources.htm#Forms
especially Dian Chapman's series of articles
If you want a custom dialog box that you code with VBA commands
you want a UserForm. Take a look at:
http://www.mvps.org/word/FAQs/Userforms.htm
7. Where can I find more information on the Web?
http://addbalance.com/word/wordwebresources.htm#webvba
http://www.mvps.org/word/FAQs/MacrosVBA.htm
http://www.mvps.org/word/FAQs/Userforms.htm
http://www.mvps.org/word/FAQs/Customization.htm
http://www.mvps.org/word/FAQs/OfficeInterdev.htm
8. Recorded macros...
http://word.mvps.org/FAQs/MacrosVBA/UsingRecorder.htm
How do I edit or change?
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm
Recorded macros are usually inefficient and sometimes just
plain don't work. Nevertheless, they often do work and can
be a good place to start!
9. How can I enter something once in a document and have it repeat
elsewhere? (Not really vba, but it keeps being asked.)
http://gregmaxey.mvps.org/Repeating_Data.htm
10. I can't save my customizations - AutoText, menus, etc.
Can't save normal.dot...
If you have Adobe Acrobat 7 installed see the last section of
http://www.gmayor.com/lose_that_adobe_acrobat_toolbar.htm.
Otherwise, hold down the Shift key when selecting the File
menu and select Save All.
See also http://www.adobe.com/support/techdocs/331259.html.
11. How can I get a template to show up under a tab with
File => New?
What are templates? Global templates? Document templates?
http://addbalance.com/usersguide/templates.htm
Comments / corrections / additions may be sent to
wordfaq@no.spam.addbalance.com. Remove no.spam from the
address. (This is a "proofed" email address, I hope.)
Posted 3 March 2006
Charles Kenyon (the editor) Tag: how to play a sound when Word starts Tag: 82037
How To Select a Row Within a Nested Table Programatically?
Hi, Everyone.
I'm dealing with a table, which has a nested table in each row of
column 9. What I would like to do is to take a specifc row of this
nested table, and copy that row into column 10. My problem is I can't
get the code right to refer to a specific row within this nested table.
Here's my code:
Dim mtable As Range
Set mtable = ActiveDocument.Tables(2).Range
mtable.Rows(5).Cells(9).Select
My problem is that this code selects the entire nested table, rather
than a row within the nested table. Can anyone set me straight?
Thanks! Tag: how to play a sound when Word starts Tag: 82035
permanently turning off the reviewing toolbar
I know that a macro exists for doing this as somebody very kindly told me
about it last month. Unfortunately, I can't find this info so would
appreciate some help. Tag: how to play a sound when Word starts Tag: 82034
Document Template loading slowly
I have a document template with approximately 150 check boxes and text boxes.
It loads and opens very, very slowly. Is there anything that can be done? Tag: how to play a sound when Word starts Tag: 82031
Word should include a function for marking essays
As a university lecturer, I feel that word should include a function similar
to the reviewing function to enable students to submit essays by e-mail
attachment as a word document. This would make the marking process easier and
quicker, and enable students to get a better standard of feedback.
The function should include capacities to: add comments both in the margins
and at the end of the document; show/hide/remove comments added by individual
markers; show/hide/remove changes made to the document eg changes to
punctuation or spelling; add a provisional/final mark in a way similar to the
way footnotes/endnotes are added. There are far more things such a function
could do, but at root it would be very similar to the reviewing function
already available in word, and therefore it wouldn't be too difficult to
create such a function.
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/community/en-us/default.mspx?mid=c86f9881-032e-49b9-9870-89b21e3bb151&dg=microsoft.public.word.vba.general Tag: how to play a sound when Word starts Tag: 82027
how to set rightAlignment in a cell ???
Hi,
Using cells in a table :
how do you set the rightAlignment for text in the cell ?
thx
Chris Tag: how to play a sound when Word starts Tag: 82025
Count words with computeStatistics
hello everyone
Im trying to select the text in a section
count the number of words(without using readabilityStatictics.value(1)
put it in the header
SO far I have comeup with the following code which gets error at the 4th
line.
Sub bbb()
Dim lngWords As Long
ActiveDocument.Bookmarks("\section").Select
lngWords = ActiveDocument.Selection.Range.ComputeStatistics(wdStatisticWords)
ActiveDocument.Bookmarks("fff").Select
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertAfter Text:=lngWords
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="fff"
ActiveWindow.Panes(2).Close
End Sub
Any help would be appreciated
thanx
ahmed Tag: how to play a sound when Word starts Tag: 82024
Template Save Changes (Word 2000)
Hello all,
When I make document based on a template, after closing or saving Word 2000
keeps asking me if I want to savechanges. Can somebody help me stopping this?
Even when I agree on saving the changes, the second time Word 2000 asks the
question. Tag: how to play a sound when Word starts Tag: 82020
Cannot use Enter Key in my UserForm TexBox
I have created a UserForm which works great, except, when the text box
appears I can type info but when I try to get to a new line by pressing Enter
it acts as a tab and moves the cursor to the next TextBox.
How do I fox this? Tag: how to play a sound when Word starts Tag: 82016
Does the Selected Range include a merged or split cell?
This is a multi-part message in MIME format.
------=_NextPart_000_001D_01C63E47.A6771520
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
That is my 64 million dollar question today.
Some of you may know that I am working on a macro to report table and =
cell data. Fruit of my labor so far is
http://gregmaxey.mvps.org/Table_Cell_Data.htm
Take the situation where you create a 5x2 table and merge B2 and C2
Then select A1,B1,C1,A2,B2.
If you run TableCellHelper from Macros8.Dot, it will report the selected =
range as A1:B2. While that may appear correct on the screen =
{=3Dsum(A1:B2)} will return will not correctly sum the value of the =
selected cells.
For that reason, I have elected to exclude selection range reporting if =
the table contains split or merged cells:
If Selection.Tables(1).Uniform Then
Report span
Else
Don't report span
End If
That seems a huge concession. For example if I have a 20x50 table and =
merge S50 and T50, I have effectively deep sixed range reports for the =
remaining million or so selection possibilities :-(
Now I am thinking maybe I should just report the range with the =
disclaimer that if the table is not uniform then the reported range may =
be in doubt. =20
After a working lifetime of dedication to trying got put ordnance on =
target, that seems cheesy ;-)
So, can anyone help me answer the question (in VBA lingo): =20
If Selected range of cells is free of split or merged cells that would =
booger up a range report
Report span
Else
Don't report span
End If
As always thanks for your time.
=20
--=20
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
------=_NextPart_000_001D_01C63E47.A6771520
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#f8f2d6>
<DIV>That is my 64 million dollar question today.</DIV>
<DIV> </DIV>
<DIV>Some of you may know that I am working on a macro to report table =
and cell=20
data. Fruit of my labor so far is<BR> <A=20
href=3D"http://gregmaxey.mvps.org/Table_Cell_Data.htm">http://gregmaxey.m=
vps.org/Table_Cell_Data.htm</A></DIV>
<DIV> </DIV>
<DIV>Take the situation where you create a 5x2 table and merge B2 and =
C2</DIV>
<DIV>Then select A1,B1,C1,A2,B2.</DIV>
<DIV>If you run TableCellHelper from Macros8.Dot, it will report the =
selected=20
range as A1:B2. While that may appear correct on the screen =
{=3Dsum(A1:B2)}=20
will return will not correctly sum the value of the selected =
cells.</DIV>
<DIV> </DIV>
<DIV>For that reason, I have elected to exclude selection range =
reporting if the=20
table contains split or merged cells:</DIV>
<DIV> </DIV>
<DIV>If Selection.Tables(1).Uniform Then</DIV>
<DIV> Report span</DIV>
<DIV>Else</DIV>
<DIV> Don't report span</DIV>
<DIV>End If</DIV>
<DIV> </DIV>
<DIV>That seems a huge concession. For example if I have a 20x50 =
table and=20
merge S50 and T50, I have effectively deep sixed range reports for the =
remaining=20
million or so selection possibilities :-(</DIV>
<DIV> </DIV>
<DIV>Now I am thinking maybe I should just report the range with =
the=20
disclaimer that if the table is not uniform then the reported range may=20
be in doubt. </DIV>
<DIV> </DIV>
<DIV>After a working lifetime of dedication to trying got put ordnance =
on=20
target, that seems cheesy ;-)</DIV>
<DIV> </DIV>
<DIV>So, can anyone help me answer the question (in VBA lingo): =
</DIV>
<DIV> </DIV>
<DIV>If Selected range of cells is free of split or merged cells =
that=20
would booger up a range report</DIV>
<DIV> Report span</DIV>
<DIV>Else</DIV>
<DIV> Don't report span</DIV>
<DIV>End If</DIV>
<DIV> </DIV>
<DIV>As always thanks for your time.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><BR>-- <BR>Greg Maxey/Word MVP<BR>See:<BR><A=20
href=3D"http://gregmaxey.mvps.org/word_tips.htm">http://gregmaxey.mvps.or=
g/word_tips.htm</A><BR>For=20
some helpful tips using Word.<BR></DIV></BODY></HTML>
------=_NextPart_000_001D_01C63E47.A6771520-- Tag: how to play a sound when Word starts Tag: 82014
Word Control Help Please
Hello,
I have a couple of documents that I would like to automate with the use
of Word Controls, macros and a standard template to be put it the word
startup folder. On the template document there are 4 controls:
TextBox1, TextBox2, TextBox4 and cboFrmNbr. When I run my macros form
within the Template everything works successfully. So I created 2
Toolbar buttons to run each macro. When open up one of the word
documents containing the same three controls (controls named the same)
I can't get the macros to run. I get an error message stating Error
Occured: Object Required. So my question is how to I read/write values
in textboxes and list boxes in a new document via a template that is
starting up when word starts up.
Any help would be greatly appreciated!!!!
Thanks in Advance,
-SK
Here is a snipet of what I'm trying to do:
Public Sub CommandButton1_Click()
Dim dte As String
Dim dte1 As String
On Error GoTo errHandle
'--Clearing the barcode values from the label object
clrLabel
dte = Format(Now, "mm/dd/yyyy")
dte1 = Format(Now - 1, "mm/dd/yyyy")
cboFrmNbr.Clear
TextBox1.Text = ""
'--Date control for displaying the DATE information
TextBox2.Text = dte
TextBox4.Text = dte1
'--Populating the combo box with form name values
sSentenceCnt = ActiveDocument.Sentences.Count
'--Populating the combo box
PopulateCombo
Exit Sub
errHandle:
MsgBox "Error Occured : " & Err.Description, vbOKOnly,
"Information"
Exit Sub
End Sub
Private Sub PopulateCombo()
Dim objCon As ADODB.Connection
Dim objCom As ADODB.Command
Dim objRS As ADODB.Recordset
Dim k As Integer
On Error GoTo errHandle
Set objCon = New ADODB.Connection
Set objCom = New ADODB.Command
'--Creating the DB connection string
'--Please change the below connection string as per your server and
database being used.
'--objCon.ConnectionString =
"PROVIDER=SQLOLEDB.1;PASSWORD=password;PERSIST SECURITY
INFO=TRUE;Initial Catalog='Northwind';USER ID=sa"
objCon.ConnectionString = "Driver={SQL
Server};Server=********;Trusted_Connection=no;Database=WAM;Uid=*****;Pwd=*****"
'--Opening the connection
objCon.Open objCon.ConnectionString
'--assigning the command object parameters
With objCom
.CommandText = "SELECT formnum from tblforms" 'Name of the
stored procedure
.ActiveConnection = objCon.ConnectionString
End With
'--Store the result in a recordset
Set objRS = objCom.Execute
objRS.MoveFirst
MsgBox "DB Connected " & objRS.RecordCount
'--Open the recordset
Do While Not objRS.EOF
For k = 0 To objRS.Fields.Count - 1
cboFrmNbr.AddItem objRS!formnum
Next
objRS.MoveNext
Loop
'--Close the recordset
objRS.Close
'--close connection
objCon.Close
'--cleaning up
Set objCom = Nothing
Set objCon = Nothing
Set objRS = Nothing
Exit Sub
errHandle:
MsgBox ("Error occured : " & Err.Description), vbOKOnly
End Sub Tag: how to play a sound when Word starts Tag: 82012
Centralizing Text in Label or TextBox
Hello!
Could anyone enlighten me how to centralize VERTICALLY the text (i.e. the
caption) in the Label or TextBox in a UserForm?
Thanks.
zhj23 Tag: how to play a sound when Word starts Tag: 82005
How get the " ` " over a letter as in touche`?
In the subject the " `" is one space to the left of the "e". Anyone
know the keyboard code for making the letter with the slash directly
over it?
Followup: What's that slash mark called, anyway?
Cheers, TomBk Tag: how to play a sound when Word starts Tag: 82004
MS Engineers: Word 2003 Find/Change Automation from Excel 2003 cra
This is a repost from an earlier post in the Excel->Programming forum. No one
has any ideas how to solve this over there. Since posting over there,
however, I have also tried to run this code as a Macro from within Powerpoint
2003, and I get the same results but a different error: "Method 'replacement'
of object 'Find' failed.": Yes, it crashes PowerPoint 2003, just like Excel
2003, so it must be Word's automation, type library or objects, or
something... Here's the post:
I just upgraded to Office Professional 2003 from Office Professional XP.
The following code, when executed, completely and irrevocably crashes
Microsoft Excel 2003 at the line <.Text = "^pDescription">. It worked just
find in Microsoft Excel XP. It even asks to send a report to Microsoft. Every
time. Easily reproducible. I have updated to all service packs/patches, etc.,
too.
Also, the line <Selection.Find.Replacement.ClearFormatting> gives a
"Automation error: the procedure number is out of range" error, which it
didn't do before in Excel 2003.
What the heck happened between the two versions? Now my code has completely
blown up!!! Any ideas????? Any help would be greatly appreciated, as we have
to get this program up and running for production! Thanks!!!
Public Sub Test()
Dim appWord As Word.Application
Set appWord = New Word.Application
appWord.Documents.Add
appWord.Selection.Find.ClearFormatting
appWord.Selection.Find.Replacement.ClearFormatting
With appWord.Selection.Find
.Text = "^pDescription"
.Replacement.Text = "-----"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
appwordSelection.Find.Execute Replace:=wdReplaceAll
appWord.ActiveDocument.SaveAs "C:\TEST.DOC"
appWord.ActiveDocument.Close
appWord.Quit
Set appWord = Nothing
End Sub
Any ideas? Thanks in advanced? Tag: how to play a sound when Word starts Tag: 82003
Why is loop not moving forward?
This loop works - but it stays in one place and doesn't move forward through
the document. What simple silly thing have I forgotten?
With doc.Content.Find
.ClearFormatting
.Style = "TOCpageref"
.Wrap = wdFindContinue
Do While .Execute(Forward:=True, _
Format:=True) = True
Selection.Collapse wdCollapseStart
Set fldPgNo = doc.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldPage)
strPgNo = fldPgNo.Result
fldPgNo.Delete
MsgBox strPgNo
Loop
End With Tag: how to play a sound when Word starts Tag: 81997
Good idea or bad?
I'm thinking of some action I'd like to perform in a report document, and it
would be really convenient to use a single "hot key" for each of them. This
would be like running once through the document performing one of six
different actions. Maybe the function keys, since they wouldn't be used for
much of anything else during these operations.
Would it be a good idea or not to run a macro which captures a specific
keystroke and temporarily changes the response, returning the normal
function on macro close? Maybe controlled by a modeless UserForm, as a
visual reminder the macro is still running? What would be the pitfalls?
Ed Tag: how to play a sound when Word starts Tag: 81995
In a macro I want to open unnamed files like *.*?
I want to sequentially open all rtf files in a folder, manipulate them, save
as word files with the same name. There are over 200 and the names may change
- so I don't want to specify the actual filename. Tag: how to play a sound when Word starts Tag: 81991
find and replace text within files - how to do macro
I am trying to replace "A" text with "B" text within 15 files. The text is on
first page in all files. Is there a way I can make this change withing all
these files.
Thanks Tag: how to play a sound when Word starts Tag: 81983
Menu commands appear differently on different computers
I've created a Word 2003 template with a custom menu command that contains
styles (the STYLES menu), and it appears between the Edit and View commands.
I've tested it on three different systems, and it worked correctly. However,
when others install and open it, the menu items are inconsistent - some
people do not see the STYLES menu; others see the STYLES, but not the Edit
menu; and still others do not see either. (All correct styles appear in the
Style drop-down and right-pane list, so it's clear that part of the template
is functioning correctly.)
Any ideas about what could be causing the inconsistencies?
Thank you! Tag: how to play a sound when Word starts Tag: 81981
Assinging a macro
Hello.
I know how to assing a macro in Excel, but how do you accomplish the same
task in Word, without a bunch of programming? The situation is that I have a
macro with about 5 subs (which I didn't write). How do I simply put this
macro behind a button so that all the end user has to do is click on the
button and the macro will run?
Mark :) Tag: how to play a sound when Word starts Tag: 81980
Compatibility with Open Office
Hi
I know that Open Office is meant to be compatible with Word but does this
include the macros and the tool bar that I have made to go with my macros?
Thanks Tag: how to play a sound when Word starts Tag: 81978
How can I get a word document to play a particular sound when I first open
the document?