Calling applications from word
Hi All,
We created a PDF creation macro.
It copies the word document to a UNC path where the PDF creation is getting handled.
It the polls the Directory awaiting the conversion and provides a message box stating the PDF awas created.
We now want Word to open the PDF document but don`t know how to caal acrobat from within Word.
Regards,
Vingertop. Tag: visual basic text form field properties Tag: 42602
Inline shapes are not visible - becomes black squares
Office 2000 / Word 2000
Hi,
I have an odd problem.
Graphics - content of my inlineshapes are not visible -
the object is just marked by the six black squares in the
corners. (this only happens when they are "in line with
text")
Other shape types are fully visible.
Does anyone know if there's a reg key or any other type of
setting that controls this?
- or if there is some way that I can change this "feature".
Thanks
;o)) Henrik Tag: visual basic text form field properties Tag: 42601
menu bar on Word VBA form
Hi,
Is it possible to create a menubar (to put on File, Edit,
Help, ...) on a form in a Word VBA application?
(BTW I do NOT mean: creating an extra menubar in Word)
I don't find any feature to do so.
thanks for any help,
Ward Tag: visual basic text form field properties Tag: 42597
Convert this VB code to VBA
Hello,
What will be the equivalent VBA code for the following VB code?? (The
code prints RichTextBox control).
Private Sub cmdDirPrint_Click()
ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
If rtbPropDirections.SelLength = 0 Then
ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDAllPages
Else
ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDSelection
End If
ComDiaPropPrint.ShowPrinter
printer.Print ""
rtbPropDirections.SelPrint printer.hDC
printer.enddoc
End Sub
Thanks
Kumar Tag: visual basic text form field properties Tag: 42588
NOT updating date fields automatically at open
I've got an app that opens and prints to image large
numbers of Word docs. Does anyone know of a way to keep
the date fields from updating when I open/print the
document? I want to preserve the original date in the
document.
Thanks much-
Tom Tag: visual basic text form field properties Tag: 42584
Word as E-mail editor using Macros
I have written macros to send active word documents and active e-mails to a folder for archive purposes.
I am having a problem when Word is the e-mail editor. Outlook uses the Word macros (both have different descriptions and coding). I had thought about taking the information off the "Word" e-mail, pening outlook with Set objApp = CreateObject("Outlook.Application") and transferring the information to the Outlook e-mail, but I cannot figure out how to code pulling the data off of the "Word" e-mail. If anyone has any possible suggestions please let me know...Thank Tag: visual basic text form field properties Tag: 42583
Lanquaqe Settings
I have received a document from a client that has to be
processed down to HTML. The problem is with a bug in
Microsoft's HTML filter which mistakeningly removes all
spaces surrounded by the <span style='mso-fareast-font-
family:"Arial Unicode MS"'> </span>.
Is there a means to reset this in the document itself
through VBA so that this tag is not output in the HTML?
Thanks
Mark Baird Tag: visual basic text form field properties Tag: 42581
controlling tab destination
I have created a form in Word with many blanks to fill
in. I want to dictate the order the cursor will advance
to when the tab key is hit. I understand that this has to
be done in VB. I am not VB savy... is there a simple
script someone can share to accomplish this proceedure?
Please help and thanks. Tag: visual basic text form field properties Tag: 42580
inserting HTML in word
Hi all,
I am trying to figure out how to write some string "as HTML" In word using
vbscript. For instance, if you copy some formatted html from IE and then do
a past in word, it shows up as Formatted HTML with the tags rendered
properly. I want to manually build an HTML string and render it to the
document so that it displays as rendered HTML and not the "<tag> text <tag>"
raw HTML.
I am stuck on this for quite some time. I am building the word document
programmatically on the client using vbscript and cannot seem to get this
last bit working. I've scoured VBA articles(I've mostly ported VBA examples
to vbscript for the project so far).
Any help GREATLY appreciated!
Thanks,
Chris Tag: visual basic text form field properties Tag: 42579
Word 2000: TypeParagraph causes Font to Change
Does anyone know how I can issue a .TypeParagraph on my selection object
without having the font change to my Default Font?
I have a template where I am inserting text into the document. In my
Template, the entire document has been formatted to use Arial font.
However, my Default Font is "Times New Roman" for my Microsoft Word (Select
Format/Font from the main menu).
My sample code is below:
With Selection
' Enter some dummy text - the font is Arial at this point
.TypeText Text:="This font is Arial"
' Now issue a new paragraph - just like pressing the ENTER key
.TypeParagraph
' Now my Font is my default font - Times New Roman
.TypeText Text:="Now my font is Times New Roman, NOT Arial"
End With
Why is my font changing? If I go into blank document and start typing my
sample text with Arial font, and press the ENTER key, my font does not
change, why is it changing here when I issue the .TypeParagraph?
According to the following MSDN article on the TypeParagraph,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/office97/html/output/F1/D4/S5ADCE.asp,
"This method corresponds to the functionality of the ENTER key". Has
something changed from Office97 to Office 2000? Tag: visual basic text form field properties Tag: 42578
FileSearch macro returning incorrect docs?
I have a macro in an Excel workbook that takes the values in certain cells
to create a search string. The macro then searches all the Word docs in a
single folder for docs containing that string. Normally it works well -
normally, though, I use only single words. Today, however, I used phrases,
and the search returned two documents that didn't fit what I thought my
criteria were!
I stepped through this and moused over my variables, and they all looked
correct. In cell E9, I had "Blackbox Code: 1.9" - this is the one that
caused the false returns. One document had "Blackbox Code: 1.7.9.2", which
I guess is close; the other had "Blackbox Code: 1.3.5" - it did not contain
"1.9" anywhere! One of the other cell values was "XM/SC Class: ABD", and it
gave me no problems. Additional note: the three variables were put in the
search string with ANDs.
If anyone can make suggestions on improving this code to keep this from
happening again, I would be most grateful.
Ed
Sub z()
Dim lngIndex As Long
Dim strSearchFor As String
Dim strLocation As String
Dim rngFiles As Range
Dim strName As String
Dim ListEnd As String
strLocation = ThisWorkbook.Path
If Range("B15") <> "" Then
ListEnd = Range("B65536").End(xlUp).Row
Range("B15:B" & ListEnd).ClearContents
End If
strLocation = ThisWorkbook.Path
If Range("E5") <> "" Then
strSearchFor = Range("E5").Text
If Range("E7") <> "" Then
If Range("D6") = "And" Then
strSearchFor = strSearchFor & " and " & Range("E7").Text
Else
strSearchFor = strSearchFor & " or " & Range("E7").Text
End If
If Range("E9") <> "" Then
If Range("D8") = "And" Then
strSearchFor = strSearchFor & " and " & Range("E9").Text
Else
strSearchFor = strSearchFor & " or " & Range("E9").Text
End If
End If
End If
End If
If strSearchFor = "" Then
MsgBox "Nothing to search for", vbExclamation
Exit Sub
End If
strName = Range("E3").Text
With Application.FileSearch
.NewSearch
.LookIn = strLocation
.SearchSubFolders = False
.TextOrProperty = strSearchFor
.MatchTextExactly = True
.Filename = "L5-" & strName & "*.doc"
.Execute
Set rngFiles = Range("B15")
rngFiles.Offset(0, 0) = "Found " & .FoundFiles.Count & " containing
" & .TextOrProperty
For lngIndex = 1 To .FoundFiles.Count
ActiveSheet.Hyperlinks.Add Anchor:=rngFiles.Offset(lngIndex, 0),
Address:=.FoundFiles.Item(lngIndex)
Next
End With
End Sub Tag: visual basic text form field properties Tag: 42577
Message Boxes
Please could someone help. I am trying to get a message box to give an A or
B option. In otherwords if you choose A it would save into Town or B into
Country. I only know how to get a Yes No situation. Could anyone help
please. I have put the example of what I am trying to get to work below.
Margaret
Dim intMsgBoxResult As Integer
intMsgBoxResult = MsgBox("Town or Country", vbYesNo + _
vbQuestion, "Current Status")
If intMsgBoxResult = vbYes Then
With Dialogs(wdDialogFileSaveAs)
.Name = "C:\My Documents\Town Details 2003\"
.Show
End With
Else
With Dialogs(wdDialogFileSaveAs)
.Name = "C:\My Documents\Country Details 2003\"
.Show
End With
End If Tag: visual basic text form field properties Tag: 42576
Information From Excel97 into Word97
I recieve several Excel spreadsheets on a daily basis containing technical information, this information is then extracted from the spreadsheet and placed into a Word document. A seperate Word document gets created for each spreadsheet which is exactly what I want and the data that gets extracted from Excel always comes from the same cells.
I can use copy and paste special etc. in order to insert the information into the Word template however I have to do this each time.
1. As I am using a word template and the data in the spreadsheet will always be in the same cells is it possible to just update all of the 'paste special' links in one go, in order to point it at a different spreadsheet ?
2. When I use the 'paste special' function to paste text into word from merged cells (Formatted Text RTF and paste it as a link this is required), a tab gets inserted after the text for each of the merged cells. Is there any way around this ?
Thanks
Tappie Tag: visual basic text form field properties Tag: 42575
do not display changes
I am trying to create a table in word using VBA (macro)
I do not want the users to see as the table is being
created.. How do I make the changes not visible untill the
entire processed is finished?
someting similar to the following command in Excel
ExecuteExcel4Macro "echo(false)"
any help would be appreciated..
thanks Tag: visual basic text form field properties Tag: 42574
Difference between running and stepping makro
Hi
I have written a macro for Word that fills text from textfiles into
specific places in my word-document.
My problem is, that if I step through the code in the debugger, then
everything works just fine, but if I run the macro then it fails.
My document looks like this:
2.1 Headline
2.1.1 Subheadline
2.1.2 Subheadline 2
2.2 Headline 2
2.3 Headline 3
2.4 Headline 4
My problem is that it is only in 2.4 it doesn't work. The output is
supposed to be like this:
2.4 Headline 4
text, more text and a lot of more text
But the output is actually something like
2.4
2.5 text, more tet and a lot of more text
2.6 Headline 4
But only when running the macro and not when I step through it. Does
anyone have any ideas?
Thanks in advance!
--
Jan Eliasen, representing himself and not the company he works for. Tag: visual basic text form field properties Tag: 42570
Constant problem
Hi NG!
Im trying to automate Word from Access and it works Ok, except for this
line:
wdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
Apparently Access VBA will not recognize wdAlignParagraphRight as a word
constant, and think of it as a Variable.
I have set a reference to the Word 10.0 Object library.
If I declare it as a Variable in Access, it expects it to have a value. Do
you know how i can do this?
All I really want to do is to right aling one paragraph, then reset to left
alignment.
Regards
Jan Tag: visual basic text form field properties Tag: 42566
Word 2000, 2002 and 2003?
Hi Folks,
Can anyone point me in the direction of in depth information about these
products please? I'm looking to get into the Object model level of these
products and the changes between versions (which I know there are) but can't
seem to find any helpful resources with the level of documenttaion I need.
I know there have been changes in the selection and range objects between
2000 and 2002/3 and I would like to know about any problems encountered
between versions.
Also the database side of things would be nice to find out about too! file
formats, conversion issues etc and how this relates to an comercial
enterprise with a large network running different platforms.
Any pointers appreciated
J Tag: visual basic text form field properties Tag: 42565
Index/Concordance problem
I'm creating an index using a concordance file. The index creates fine, but it seems to randomly miss entries and sub-entries. Any suggestions on what could be occuring? Also, in a 2 column format, is there a way to get the second index page to use only the first column on the second page?? Word splits what's left over into 2 columns and I'd like to get it to just put the entries in the first column
THX Tag: visual basic text form field properties Tag: 42554
AutoOpen - How to Hide it from Alt-F8
I have an AutoNew subroutine that is declared as Public, so that when a user
creates a new document from our template, this code will be the first thing
to run. How can I have this subroutine hidden from the list of available
Macros that the user can run? If the user clicks Alt-F8, they are presented
with a list of Macros, including my "AutoNew" macro. If I change it to a
Function, it will not show, however, by changing it to a Function will
prevent it from running when the user creates a new document. Tag: visual basic text form field properties Tag: 42553
Find/Replace with special characters
The following snippet of code will replace occurences of
these SGML entities with special characters that are
pretty close to the original output:
' Entities
' Handles &circle; entity
Selection.HomeKey unit:=wdStory
With Selection.Find
.ClearFormatting
.MatchWildcards = False
.Text = "&circle;"
While .Execute
Selection.Range.InsertSymbol _
Font:="Wingdings 2", CharacterNumber:=-3943, _
Unicode:=True
Wend
End With
' Handles • entity
Selection.HomeKey unit:=wdStory
With Selection.Find
.ClearFormatting
.MatchWildcards = False
.Text = "•"
While .Execute
Selection.Range.InsertSymbol _
Font:="Wingdings 2", CharacterNumber:=-3944, _
Unicode:=True
Wend
End With
So far so good. But how can I code this so that
occurences of these entities are replaced in the
header/footer?
-Yeager Tag: visual basic text form field properties Tag: 42546
Macro errors after installing Q822036
Am I the only one who had macros fail after installing the latest security
patch. 822036
More Details:
Fully patched WinXP and OfficeXP.
Running macros in Word that look for a footer on the last page of a document
as in Q 209220.
If the footer is found it is removed.
All of a sudden I have two errors.
1. I get a run-time error 4605 saying "This command is not available."
'ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument'
OR
2. The macro finishes, but I can not switch "views" by using the four little
view buttons on the Lower Left hand corner of the Word window, these are the
"Normal view, Web Layout view, Print Layout view, Outline view".
Once I switch from Word to another program then switch back into Word these
buttons are working again.
Anybody else see any problems with the new pacthes.
Matt Tag: visual basic text form field properties Tag: 42544
vba word question
Hi all,
I am trying to figure out how to write some string "as HTML" In word using
vbscript. For instance, if you copy some formatted html from IE and then do
a past in word, it shows up as Formatted HTML with the tags rendered
properly. I want to manually build an HTML string and render it to the
document so that it displays as rendered HTML and not the "<tag> text <tag>"
raw HTML.
I am stuck on this for quite some time. I am building the word document
programmatically on the client using vbscript and cannot seem to get this
last bit working. I've scoured VBA articles(I've mostly ported VBA examples
to vbscript for the project so far).
Any help GREATLY appreciated!
Thanks,
Chris Tag: visual basic text form field properties Tag: 42543
Word Object
Hello All!
I need help for programming Equation Object
example.
I paste to Word document new Equation Object
Selection.InlineShapes.AddOLEObject ClassType:="Equation.3",
LinkToFile:= _
False, DisplayAsIcon:=False
and I'll must program my new object with some rules
1.
10
Q= -------
A
2.
100*d
Q= -----------
A*b
Can I program Equation.object?
And Where I can find help files about methods or properties of
Equation.object.
Thanks.
Stas. Tag: visual basic text form field properties Tag: 42540
ActiveDocument.SaveAS
I'm using Office 2000, Win98.
I've developed a UserForm and trying write the code to
save it before it closes. The code I've written is:
ActiveDocument.SaveAs ("C:\WINDOWS\Desktop\Debi & ' " &
strLastSave & " " & strFirstSave & " " & strDateSave
& " ' "), wdFormatDocument
I've double checked this Path several times but I keep
getting this error message:
"Run-time error 5152
"This is not a valid File name
Try one or more of the following:
*Check the path to make sure it is typed correctly.
*Select a File from the list of Files and Folders."
I've copied and pasted the path from Window's Explorer, so
I know the path is correct.
I can do this in Visual Basic 6.0 and I know that VBA is
not quite like VB6.0, but could someone help me code a
SaveAs?
I greatly appreciate the time and effort put into any help
you give.
Debi Tag: visual basic text form field properties Tag: 42538
out of memory error 7
When I click on a form object/control in VBA word during programming I get the error 7 message. It is not a 64k limit issue or other memory issues. I am using word 2002 alone with NT home edition. Any ideas???? Please help..... Tag: visual basic text form field properties Tag: 42537
Arrays
I wonder if someone could direct me to a simple use of an array. I
can't make any sense out of the material on arrays in Word 97 VBA Help.
I would just like to get a idea of what they are and what a practical
use of them would be.
Larry Tag: visual basic text form field properties Tag: 42536
The RichText box problem in Word2003
Re the problem with a RichText box not showing up on the UserForm in Word
2003, this is a Microsoft Rich Textbox Control 6.0 (SP4). Isn't this part
of Visual Studio? From my partner:
Yes the ocx is on the machine. It appears in References. Security has been
set to low.
It works on ther versions of Word, so registering should not be an issue.
If anyone can point out further ways to figure this out, we would really
appreciate it. Tag: visual basic text form field properties Tag: 42532
ToolsGrammarStatisticsArray
I have a Word macro that uses the
ToolsGrammarStatisticsArray. My document is 13 pages
long. When I run the Word macro on my 13 page document in
Word 2000 I get an error message that
states "ToolsGrammarStatisticsArray cannot be run on a
document that contains more than one language format".
When I open the same document and run the same macro in
Word 6.0, I do not get this message. How can I get it to
run in Word 2000? The macro works on a new document in
Word 2000. Tag: visual basic text form field properties Tag: 42531
maximum size log file?
Hello,
I have a VBA application, in which I also write debugging
information to a log file, using the following statement:
Open LOG_FILE For Append As #1
Print #1, PrefixText & tMessage
Close #1
Does anybody know how big this file can get before the
application will generate an error? I.e. what is the
maximum file size to write to?
thanks for any help,
Ward Tag: visual basic text form field properties Tag: 42525
RichText in Word
Hi,
I=B4m Roby, vb Developer.
I=B4m trying to paste some RichText in the Word, but=20
without success.
Paste it in the Word will only show the RichText Script.
Please Help!
Thank you,
Roby E Martins Tag: visual basic text form field properties Tag: 42522
detection of end-of-paragraph
Dear experts
how can I detect an end-of-paragraph sign, namely ChrW(10)? I want to extend a selection as far as the next blank appears or the next end-of-paragraph sign through
Do While Not (Selection.Text Like "* *" Or Selection.Text Like "*" & ChrW(10) & "*"
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExten
Loo
but the loop recognizes blanks only
Best regard
Martin Tag: visual basic text form field properties Tag: 42521
How to jump to a bookmark in a pagefooter
I can't seem to jump to a bookmark in a footer.
I have to jump to a certain place in the footer, and a bookmark will be a fine way to place the text, I want to insert right there.
Can anybody help me to find the way to place the cursor at that specific point by using bookmarks? Tag: visual basic text form field properties Tag: 42520
Using MSWORD9.OLB to create Word Documents
hi all
I am trying to create a word document , using Microsoft Word 9.0 Object
Library.(MSWORD9.olb). I made a setup file of VB application with follwing
code, using deployment and setup wizard of visual studio.
Dim objApp As Word.Application
Set objApp = New Word.Application
'Start a new Normal template document
Documents.Add
'Format document heading
The code works fine on a system which got Microsoft Word 2000 installed,
whereas when i run this code on a clean system without Microsoft Office /
Word 2000 it gives out error message saying cannot create object of Activex
Component. When i do a research on this problem, i came across this info
saying
"The Package and Deployment Wizard does not recognize the *.olb file
extension as a type library and incorrectly assumes it to be a binary
executable"
from here
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:
80/support/kb/articles/q249/8/43.asp&NoWebContent=1
I need to create a word document on a system where MS - Office will not be
there. How do i do this ? Any help is appreciated
Thanks
Srinivas Tag: visual basic text form field properties Tag: 42511
File Save As Dialog
I have a form created in Word ' 97 that updates numerous
fields when the user presses an update button. At the end
of the updates a message box asks if the user wants to
save the form and if they do then are asked if they want
to save it with a new name. If yes then the File Save as
dialog box is called using this code.
x = Dialogs(wdDialogFileSaveAs).Show
My question/problem is that if the user selects the same
file name as an existing one at this point absolutely
nothing happens. I would have thought the "File Name
already Exists" message box would appear. If a diferent
file name is entered it saves without a problem.
I have tried removing the Application.DisplayAlerts =
wdAlertsNone code, setting it to "wdAlertsAll" but all to
no avail. I want the "file name already exists" message
box to appear. Your help will be most appreciated
Greg Mc Tag: visual basic text form field properties Tag: 42505
Getting spell check to ignore non-breaking double hyphens
Here's an interesting puzzle for experts. In my Word 97 documents that
use Courier (the font in which I do most of my drafts), instead of
double hyphens I use a non-breaking hyphen followed by a regular hyphen,
that is, in VBA language, Chr(30) followed by Chr(45). This keeps the
two hyphens together and keeps them both togehter with the word that
precedes them, so that they don't divide across the end of a line. I
have a macro that inserts this non-breaking double hyphen and use it all
the time.
Unfortunately, spell check stops at each non-breaking double hyphen. (I
get around this with a macro that converts the font to Arial and the
double hyphens to M dashes; then another macro that the document to its
original format when I'm done.) But I just noticed today that spell
check does NOT stop at regular double hyphens.
My question is, is there any way that I can get spell check to ignore my
special non-breaking double hyphens? I tried selecting a non-breaking
double hyphen and applying "no proofing" to it, but that didn't do the
trick.
Thanks
Larry Tag: visual basic text form field properties Tag: 42502
printbutton in Worddocument
I want to use a printtbutton in Word. I know it is easy, but I don't know
how it was.
What steps doe I need to make a button in a document to print that document
Rlo Tag: visual basic text form field properties Tag: 42499
printbutton in document
I want to use a printtbutton in Word. I know it is easy, but I don't know
how it was.
What steps doe I need to make a button in a document to print that document
Rlo Tag: visual basic text form field properties Tag: 42498
listing which documents were changed by macro
I have a macro which goes through hundreds of documents
and changes old product names to new product names. This
uses Word's find and replace functions. After the macro
is finished, I would like to have a list of which
documents were changed and which were not. I have to
redistribute hard copies of the documents that were
changed, so I don't want to worry about the documents that
were not changed.
Is there a way to know whether a find/replace search for a
document made any changes or not? Thanks. Tag: visual basic text form field properties Tag: 42493
Word scripting problem
Hi all,
I am trying to figure out how to write some string "as HTML" In word using
vbscript. For instance, if you copy some formatted html from IE and then do
a past in word, it shows up as Formatted HTML with the tags rendered
properly. I want to manually build an HTML string and render it to the
document so that it displays as rendered HTML and not the "<tag> text <tag>"
raw HTML.
I am stuck on this for quite some time. I am building the word document
programmatically on the client using vbscript and cannot seem to get this
last bit working. I've scoured VBA articles(I've mostly ported VBA examples
to vbscript for the project so far).
Any help GREATLY appreciated!
Thanks,
Chris Tag: visual basic text form field properties Tag: 42491
Visual Basic error
I am getting the following error when I open Micorsoft Word while Outlook
is open (Office 2003)
"Microsofrt Visual Basic
Compiole error in hidden module: Auto Exec"
How do I correct this?
R o b e r t E F i n e Robert E Fine refine13@adelphia.net "Knowledge is of
two kinds: we know a subject ourselves, or we know where we can find
information upon it." Life of Johnson (Boswell). Vol. v. Chap. ix. 1775. Tag: visual basic text form field properties Tag: 42486
Locking the section
Hello,
I wanted to lock certain lines of the word document. To achieve this,
I have defined bookmarks at these locations and inserted section
breaks. It works fine. It allows me to lock the text in the protected
section. However, it doesnot maintain the location of the bookmark..If
I delete certain lines above the section, the section along with the
bookmark shifts up. I wanted to freeze the location of the bookmark
(section). Any ideas?
Thanks
Kamur Tag: visual basic text form field properties Tag: 42478
Separating a string
I am using Word 97 and I want to be able to pickup a
person surname from their full name which has previously
been stored with a string entitled sName.
Can someone assist me please
Thanks
Mark Tag: visual basic text form field properties Tag: 42472
Count files in diectory
Hello,
Kind of new to VBA in Word, but I have an opportunity to use it.
I want to know if it is possible to count the number of files in a
directory. My ultimate goal is to save a file as <filenametext??> where the
"??" is the filenumber count + 1. If that is too hard I can just add a
msgbox with the next file name and have the user save the file manually.
The need for this macro is to help users save a copy of a protected document
in the proper directory with the proper name. My plan is to write a
procedure that would fire automatically when the user tries to type onto a
protected document.
Thanks,
Jim Tag: visual basic text form field properties Tag: 42470
Deleting table based on contents of a bookmark
I appreciate the help received from Doug and Jean-Guy in
response to my November 11 post concerning deleting tables
based on the contents of a particular bookmark in a forty-
page Word 2000 form used to collect information from
faculty about their activities.
The code works perfectly, and is included at the end of
this post for reference.
Four questions about our project have come up that I am
unable to answer, no doubt because this is my first vba
project. I have looked through the MVPS Word FAQs, and the
subject lines in the vba.beginners and vba.general lists,
but haven't found solutions yet, though I may have
overlooked a posting that would be helpful.
1. How do I include my vba code as part of a Word 2000
form emailed as an attachment?
I tried to email a test version of the form to a colleague
and myself so we could test it, but found that no vba code
was included along with the attachment when I opened the
form and then the VB Editor (from Tools->Macro->VB
Editor). I believe I correctly saved the code along with
the document (not in Normal) before sending the email with
attachment, but there was no sign of any vba code.
I emailed myself the code separately, and pasted it into
the code window of the VB Editor, and then it works fine.
But this is too complicated for the faculty to do.
I've read 'Distributing macros to other users' and 'What
do I do with macros sent to me by other newsgroup readers
to help me out?' but neither really addresses how one
sends a Word form as an attachment when the form includes
vba. The fact that I haven't found any FAQ references to
what must be a common activity, leads me to conclude that
I'm missing something really obvious!
2. How do I make a macro button run the vba code
associated with my form?
The code works fine when I run it from within the VB
Editor using the 'Step Into' button where I can observe
its operation, and also runs fine from the 'Run' button,
but only when the cursor is at the first line of the Sub()
in the code window.
I'm not clear about how to attach my macro button to the
code it is supposed to activate: when I click on the macro
button, the cursor simply moves into the first field in my
form, if I double click, the cursor moves into the second
field in the form, but in either case does not run the Sub
code as I would have expected. I do of course have the
name of the vba routine in the macrobutton. The macro
button is located at the end of section 3 (please see
following question).
3. How do I run the 'delete empty tables' code on only
sections 2 and 3 of the three-part form?
The form is in three sections, with a section break
following each of the first two sections with each new
section starting on the next page (Insert->Break-
>PageBreak->Next Page). We want to run the 'delete empty
table' code only on sections two and three, and include
the related numeric total (from Cell 1,1 of any remaining
tables) at the end of section two or three, rather than
the one GrandTotal that is generated now.
4. In the tables that remain after running the 'delete
empty tables' code, how do I delete rows that haven't been
used and therefore have no text in their text bookmarks,
along with completely empty 'spacer rows' (for
readability) located between rows containing text?
After looking at the results from running the code as it
is now, it occurred to us that a cleaner document would
result, if within a table that _contains_ text in its
first text bookmark (which is always row 3, column 2), it
would be possible to delete any rows that follow but that
may not contain any text. These rows may be completely
empty 'spacer rows' inserted for readability between rows
with text bookmarks, or simply another row like row 3 that
contains a text bookmark but no text in the bookmark.
Tables may contain between 2 and 16 rows having text
bookmarks.
I think the code to do this would need to:
a. Look for the last row in a table that has text in
column 2 (not just the existence of a text field, but a
text field with a Len of > 5 which seems to be the default
length of my text bookmarks for reasons I don't understand
at this point)
b. Delete rows (if any) in the table that follow this last
row.
Thank you very much for any assistance you are able to
provide with these four questions.
Peter
The current version of the code provided by Doug with
additions by Jean-Guy follows:
Sub FSR()
Dim myrange As Range, i As Integer, GTotal As Long
ActiveDocument.Fields.Update
ActiveDocument.Unprotect
For i = ActiveDocument.Tables.Count To 1 Step -1
Set myrange = ActiveDocument.Tables(i).Cell(3, 2).Range
myrange.End = myrange.End - 1
' Check row 3 column 2 to see if empty-default empty
length is 5
If Len(myrange) = 5 Then
Set myrange = myrange.Tables(1).Range
myrange.SetRange Start:=myrange.Start, _
End:=myrange.End + 1
myrange.Delete
End If
Next i
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset
ScholTotal = 0
For i = 1 To ActiveDocument.Tables.Count
ScholTotal = ScholTotal + ActiveDocument.Tables(i).Cell
(1, 1).Range.FormFields(1).Result
Next i
ActiveDocument.FormFields("ScholTotal").Result =
ScholTotal
End Sub Tag: visual basic text form field properties Tag: 42456
open website in word
hello !
how I can opened the website (it's a security website) ?
when I open this line:
http://user:pass@gulp.de/cgi-gulpsearch/gp.exe/ubprof?4401
then opening the next window and I must add manualy the user name and
password.
How to do it if I can open this website automaticaly and I not must add
manualy user name and password ?
Pawel Tag: visual basic text form field properties Tag: 42455
Return line of text iteratively
Hi All,
I'm having a hard time breaking through this barrier. I need to iteratively
go through the word documnet and pull each line individually from beginning
to end. Right now I'm just trying to write each line of text to the
debugger just to see if it'll work.
I'd really appreciate an example or some helpful pointers.
Thanks,
Zac Tag: visual basic text form field properties Tag: 42449
Word as XML
Hi
Is there a way to save a word doc as XML / Word ML
If so, does naybody know how to loop thru each of its content sections
Here is my requirement: In Windows Share Point Service, there is a provision to assign user & status to each of the WORD documents section, I'm trying to figure out how to read the docs sections & their attributes
Any help would be great
Thank
PP Tag: visual basic text form field properties Tag: 42448