Form Field on Unprotected Sheet
I have this wondrous code that I want to run when ff1 is exited. The
trouble is, this sheet is not protected, so the formfield is just deleted.
Is there any similar way to "run" code when text at that location is
entered? (I hope this question is not too unclear.)
TIA Tag: Macros seperate from doc? Tag: 42320
How to select a paragraph via VBA
I want to select a paragraph in my macro
I have this type of line
U:\totttot\toto\t
tu\laposte.xl
At present, I search the extension .xls, then I can select the line. (result : tu\laposte.xls
How can I select the entire paragraph
U:\totttot\toto\t
tu\laposte.xl
Macro use
Selection.MoveRight Unit:=wdCharacter, Count:=
Selection.HomeKey Unit:=wdLine, Extend:=wdExten Tag: Macros seperate from doc? Tag: 42319
Find the page number that a section starts on
Hi,
Does anyone know how to find the page number that a
section starts on.
I want to list all the sections within a document and to
display the page number.
Cheers,
Steven Tag: Macros seperate from doc? Tag: 42310
Memory error filling a MS Word document from MS Access
Hi,
I've got a problem with memory using MS Word..
Situation:
MS Office 2000 (fully updated)
Window w2k professional (fully updated)
I have a table on a SQL Server database.
In this table I put complete word documents as objects.
Now, I have a small vb script that copies the word object
and then pastes it in Word.
This works nice, but after a number of items, I get a
message: Not enough memory, If continuing you cannot
undo...
You can continue for a number of items, but after that
Word crashes..
I found a possible fix in the knowledge base concerning
too much edits, but this wasn't it.. I added a save
command, but I still got the problem...
Did anyone else have this problem???
Or maybe a solution??
Bye,
Sander Tag: Macros seperate from doc? Tag: 42308
Macros in IE and locally ?
Hey, I have a confusion. I have this word document that I
want customers to edit through IE with the word viewer
thing and then use a menu item I add to save it back to
the server.
Problem 1: I got how to add a menu item, but when I try to
do it on the opening of the document, it gives me an error
when I call the Add() sub when I open it in IE, but when I
open it with Word through an FTP. How can I get the menu
to be there when the user opens the doc?
Problem 2: When I couldn't get the menu to make itself on
document load so I tried making a "Make Menu" macro
button. I made the button, opened the doc with IE and
double clicked it, nothing happened, then I opened the doc
(a local copy, not thru ftp) with word, and the menus were
there just like the macro ran. Then I opened it again in
IE and the menus were there. I re-traced my steps many
times and it seems like if I run the menu macro either on
my local copy on my C drive in word, or on the remote copy
on a web server, changes show up in both places on the
next time I open the document. Why does this happen?
Any help would be much appreciated, I am stumped. Thanks
-Paul Tag: Macros seperate from doc? Tag: 42304
Testing for Duplex
I'm trying to use the excellent article at
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116
to set up a duplex option on a vba controlled print utility.
It works very well, but what i'd like to know is if there is a way to test
whether the printer supports duplex or not?
The demo function works very well
Sub PrintDuplexBooklet()
Dim iDuplex As Long
iDuplex = GetDuplex 'save the current setting
SetDuplex 3 'set for vertical binding
ActiveDocument.PrintOut Background:=False
SetDuplex iDuplex 'restore the original setting
End SubI was hoping iDuplex = GetDuplex would return 0 if there was no
duplex option, but it doesn't.Can anyone advise? Tag: Macros seperate from doc? Tag: 42296
regional settings' list seperator variable
Hi,
I've run into the following annoying, stupid issue:
Using VBA I want to do a search for 2 or more empty
paragraphs and replace them by one paragraph. Therefore I
use the following code:
With tDoc.Range.Find
.ClearFormatting
.Text = "^13{2,}" <----- problem
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
The line ".text = "^13{2,}"" is giving me problems
however. Because the comma is a list seperator, as defined
in my MS Windows regional settings dialog box (Start,
control panel, regional settings, numbers), it works fine
on my computer.
But a colleague has his list seperator set to ";". Thus,
Word pops up saying it is not a valid expression.
I want my program to work, regardless of the regional
settings. So i tried to find a variable or constant which
contains the list seperator character (be it ",", ";" or
whatever) and create the .text string accordingly; but I
didn't find any.
Any (other) solutions,
thanks
Ward Tag: Macros seperate from doc? Tag: 42287
Finding the section number
Hello
I am new to VBA, and I am writing a Word-macro
I need a way to find the section number the cursor is in.
I found the wdActiveEndSectionNumber, but that seems to always return
"2" in my macro. And I need the full number. If I am in section 2.3.1
then I need a string with "2.3.1" in it. Is this possible?
Thanks in advance
--
Jan Eliasen, representing himself and not the company he works for. Tag: Macros seperate from doc? Tag: 42286
calling functions in a global template
Hi,
How can I call a function in a global template (loaded from the startup
menu) from other document templates?
Any help is appreciated.
Raymond Tag: Macros seperate from doc? Tag: 42284
Template no longer available
I have a document with an attached template. When the document is moved to a
different computer at home the template is in a different path.
The UI (Tools>Templates and AddIns) shows the original template and path.
Clicking Organizer gives the error "This document template does not exist"
so Word is aware of the original template name.
ActiveDocument.AttachedTemplate returns Normal.dot.
Is there a way of getting the orignal template name?
Regards
John Yarrall Tag: Macros seperate from doc? Tag: 42276
Using ftp address in a macro
Hi All,
We are currently trying to do a document comparison by comparing the
active document with a file on an FTP site. When doing manually,
everything works great, but when when I record the action, and attempt
to use the macro, we get Run-time error '5273'. The macro takes the
following form:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/2/2003 by NormanJD
'
ActiveDocument.Compare Name:="ftp://1.2.3.4/Compare/test.doc"
End Sub
(IP address changed to protect the guilty)
I have tried variations such as
"ftp://username:password@1.2.3.4/Compare/text.doc" and have added the
FTP site along with username and password to the "Save as" list and in
"My Network Places" I am testing this in an environment with no
firewalls or proxies, (will add those later) but anonymous logins are
disallowed. My workstations will either be running Windows 2000 or
Windows XP with Office 2000 and all latest patches for both the O/S
and Office. I've played like crazy with IE settings, but don't think
this will help as it does wotk when I do everything manually, only the
macro fails...
Has anyone tried this or have a solution? Is this a VB/macro bug?
John Norman Tag: Macros seperate from doc? Tag: 42275
Compile Error
I seem to be getting a VBA error in Office due to some
kind of conflict with my RAV AntiVirus. I can neither
Save nor Save As. The only way to save a file is to close
the window. The error message I get is ...
Microsoft Visual Basic
Compile error in hidden module. Main.
It also comes up every time I open Word or Access or
Excel.
I've tried all the suggestions from the knowledge base,
including upgrading Adobe Acrobat. HELP!
Jim Dodds
jemd@wcvt.com Tag: Macros seperate from doc? Tag: 42272
Unable to delete Auto_close macro
I'm trying to advise a friend who had several viruses on his Windows 2000
machine. All that's left now is a macro in Word 2000 called Auto_Close. At
one point it appeared to be active when saving a document, but now it
doesn't appear to be doing anything. Nevertheless, the Delete option is
greyed out. How can we get rid of this?
We've studied this:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;211800 (What to do
if you have a Macro Virus),
tried starting Word with the Shift key down, and renaming Normal.dot, but
that hasn't helped. Nor is there any sign of it in the Organiser. What's
going on?
--
######################
## PH, London ##
###################### Tag: Macros seperate from doc? Tag: 42267
Saving to an FTP site?
How could I save to an FTP site in VBA possibly using the
SaveAs function (I tried just stuffing an ftp url with a
default username and password in as the filename where the
path should go but it didn't work). Tag: Macros seperate from doc? Tag: 42262
INCLUDETEXT, updating fields within the included text
Here is what I have:
1. document(1) has an INCLUDETEXT that drags in document(2)
2. document(2) has a bookmark
3. the bookmark of document(2) is filled with a number
from an Excel spreadsheet. When you directly open document
(2), Document_Open event goes out and gets the latest
number from the spreadsheet and puts it in the bookmark
But here's the problem:
The bookmark field is NOT updated when document(2)
is "opened" by being dragged into the INCLUDETEXT of
document(1).
I conclude from this that double-click opening a document
is not quite the same as "opening" it with an INCLUDETEXT.
Is there a VBA way to "tell" document(2) it is supposed to
update itself when it is an INCLUDETEXT?
Thank you for any assistance. Tag: Macros seperate from doc? Tag: 42260
"This is not allowed in this context" - xml markup in 03
I have attached well-formed and valid schema to my document and am able to tag most of my text successfully. Why does some of the text that I tag result in an error "This is not allowed in this context". What do I need to do to fix this? Tag: Macros seperate from doc? Tag: 42258
Deleting the Last Section
I'm trying to provide writers with a macro for deleting
the last (portrait) section of a document (in situations
where they decide that they want to end the document with
a landscape section). My users are not very good with
page formatting, so I'm trying to make it as easy as
possible.
I've started with a recorded macro that goes into the
header/footer of the last section, makes them same as
previous, reformats the page to landscape layout, and then
deletes the final section and the previous section break.
The recorded macro is not toggling properly between the
header and footer, and is not working too well... I'm
wondering if anyone has recommendations for reworking the
code.
Here's what I've got so far. I've manually modified the
code in the section marked (*), which is completely
incorrect:
========================================================
Sub DeleteLast()
'
' DeleteLast Macro
' Macro recorded 18.11.2003 by scott.adams
'
'Go to last page and set view
Selection.EndKey Unit:=wdStory
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
'(*)Reset headers and footers to same as previous
With Section.Headers
HeaderFooter.LinkToPrevious = True
End With
With Section.Footer
HeaderFooter.LinkToPrevious = True
'Return to main document and set last section to
landscape
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
Application.Browser.Target = wdBrowseSection
Application.Browser.Next
With Selection.PageSetup
.Orientation = wdOrientLandscape
End With
'Delete the last section
With ActiveDocument.Sections.Last.Range
.Delete
End With
'Remove the previous section break
Selection.TypeBackspace
Selection.Delete Unit:=wdCharacter, Count:=1
'Reset browse by object and return to top
Application.Browser.Target = wdBrowsePage
Selection.HomeKey Unit:=wdStory
End Sub
======================================================== Tag: Macros seperate from doc? Tag: 42256
edit existing autotext entries
Using Word XP VBA or VB, how can I programmatically edit
an existing autotext entry in Normal.dot?
i.e we have an entry called Dublin which has our Dublin
office details. Our office details have now changed, so
we want to change the autotext entry in normal.dot to
reflect the new details. The only results I keep on
finding all deal with Selection.Range which we won't have
in this case.
Additionally, is there any way to manipulate/set the
range.text value?
Much appreciated,
Allan Tag: Macros seperate from doc? Tag: 42255
How to copy formfield without onexit macro
Is there a way to copy a formfield without copying the
onexit macro. Currently when I copy the formfield and
paste it somewhere else using VBA it copies the text,
which is what I want, but it also copies the onexit macro,
which I don't want. Anybody know how to do this? Thx. Tag: Macros seperate from doc? Tag: 42254
VBA References
Hi Group
I've just tried to install a set of custom VBA-driven Word document
templates onto another users machine and came across a problem.
I have Word 97, and my user forms and modules reference Microsoft DAO 3.51
Object Library and Microsoft ActiveX Data Objects 2.5 Library. On the
previously untested PC these were not available, and attempting to run my
templates came up with a user-form error in hidden module. So obviously Word
doesn't auto-reference these for me. Is there a way of making my VBA script
do this in an AutoExec so that the error will not occur? Is there another
way around this problem? Any help would be much appreciated.
Best wishes
Peter Kessler
Kessler Associates
E: ka@kessler-web.co.uk
W: www.kessler-web.co.uk Tag: Macros seperate from doc? Tag: 42251
Select a page
Hello again. FYI - I am automating Word from Excel.
I have the following function that is supposed to select a
specific page in a document, it works well, unless the
target page is the LAST page in the document:
Dim wrdApp As Word.Application
Set wrdApp = GetObject(, "Word.Application")
wrdApp.Documents(argFileName).Activate
With wrdApp.Selection
.ExtendMode = False
.GoTo What:=wdGoToPage, Which:=wdGoToNext,
Name:=argPageNumber
.ExtendMode = True
.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1 ',
Name:=""
.ExtendMode = False
End With
Can someone tell me what is wrong or how I can always
concisely select an entire page no matter where it is in
the document? Your example code is most appreciated.
Thanks much in advance. Tag: Macros seperate from doc? Tag: 42245
Reference to Word
Hello. I hope someone can help me.
I am actually working on a project to automate Word from
Excel. I can start a new instance of Word, open files,
etc., but:
1. After the Word App is instantiated, my code does some
processing. Then it switches to Excel. Later, in a new
procedure, how do I re-establish a reference to Word again
(i.e. if the App is already running)?
2. If there is more than one instance running, how can I
determine in VBA which instance is the one my program
started and which is an instance the user started/already
had open?
Please note that my program will always start a new
instance of Word and work with that instance.
Your example code is what I need the most. Thank you very
much for your assistance. Tag: Macros seperate from doc? Tag: 42239
Code to Insert GIF files into a word document...
I have written some code to insert two gif files into a
word document. The code seems to work fine during the
first execution, but as soon as it runs again for the
second time i get error 462: remote server does not exist
or can't be found. It happens on the first AddPicture
statement...anyone have any ideas...thanks in advance.
here is the code:
' create the file path for the first GIF file
lsGIFImage = mid(psSourceFilePath, 1, Len
(psSourceFilePath) - 4) & ".gif"
Set lrWord = New Word.Application
lrWord.DisplayAlerts = wdAlertsNone
' create a new document from a template
Set lrDoc = lrWord.Documents.Add("ROMSWordTemplate1")
If lrDoc Is Nothing Then
lrWord.Quit wdDoNotSaveChanges
Set lrWord = Nothing
CreateOutputReport = False
Exit Function
End If
' insert the GIF's (this is where i get the error the
second time to code runs. it works the first time
thru!
Set lrShape = lrDoc.Shapes.AddPicture(lsGIFImage,
False, True, InchesToPoints(1.5), 1, InchesToPoints(6),
InchesToPoints(3.5))
lrDoc.Shapes.AddPicture mid(lsGIFImage, 1, Len
(lsGIFImage) - 4) & "-b.gif", False, True, 1,
lrShape.Height + 10
Set lrShape = Nothing
' save the new document with this file name...
lrDoc.SaveAs mid(psSourceFilePath, 1, Len
(psSourceFilePath) - 4) & ".doc"
' exit and clean up
Set lrDoc = Nothing
lrWord.Quit wdDoNotSaveChanges
Set lrWord = Nothing Tag: Macros seperate from doc? Tag: 42237
Word macro and Amipro
At work I use Word macros to tidy up specific documents, however my staff only have access to Amipro3.1. How can I convert my Word Macro into an Amipro macro so my staff get the same benefits I do. I have a Word to Amipro converter, but I don't think this will convert the Macro script
Cheers In advanc
Jo Tag: Macros seperate from doc? Tag: 42229
Comparing Documents
Hi,
I have written code to run through every story range and
pull out the revisions. This, unfortunately does not catch
changes to section headers within a storyrange (e.g. the
main story).
The compare documents function provided by word can find
them but if i search through every revision for every
story range i can't.
Any ideas?
Cheers,
Steven Tag: Macros seperate from doc? Tag: 42227
UserForm is not visible
Hi there.
I have a template with the userform frmMain.
On this frmMain I have several buttons that creates and opens new documents
based on different templates.
When I have created a new document, filled it with the desired text and
saved it, I close it.
But when this document is closed, my frmMain is NOT visible. Only the
template containing my frmMain is showing, but the frmMain is not visible.
The reason is probably that I have the code frmMain.Hide in the code that
fills out my new document with text.
But this was neccesary, or else the frmMain was placed in front of my newly
created document.
I had to close the frmMain to get to my newly created document so I could
edit it some and then save/close it.
I don't want to close my frmMain until I'm all finished with all my new
documents.
The frmMain contains a lot of textboxes the the user fills out and all this
text goes into some bookmarks on the different documents.
So I have to have access to my frmMain after closing my newly created
documents.
I have figured out that VBA doesn't support the use of modal and modeless on
the forms.
Is there any other way to switch focus between documents/userforms??
Hope this makes any sense.
Gunnar Tag: Macros seperate from doc? Tag: 42223
More than 3 dimensions in an array?
Hi Folks I've heard this can be done but it's quite difficult. Can anyone
give an example as to how this works?
I'm looking to understand 4 or 5 dimensions (not necesarily to use in code)
mainly to get the concept.
Any pointers appreciated
John Tag: Macros seperate from doc? Tag: 42216
Finding loop conditiion
Im trying to make condition for macro that is searching
for special word through the document. Im not able to make
macro stop searching procedure (it loops as many times as
word is found) and when it reaches the end, it start from
the begining. I want to make stop find procedure when it
reaches the end of document.
Help is appreciated.
Thanks.
Sasa Tag: Macros seperate from doc? Tag: 42215
Java API for MS Word
Is there Java API for MS Word. If not, is there any dll
specification that I can build JNI for. Tag: Macros seperate from doc? Tag: 42211
autoclose/autosave??
I have some code set for closing out of a word doc. The
code itself works fine, but I would like to use it on
either the save/save as or close events. Currently I
have it set up under an "autoclose" module. It works
fine if the user is closing the doc (obviously)...
however, most users will likely try using the "save" menu
option. Here is what I currently have:
Sub autoclose()
'defines variable for filename
Dim strFileNM As String
strFileNM = ActiveDocument.Variables("SOPName").Value
'changes directory default to SOP folder
ChangeFileOpenDirectory _
"C:\Documents and Settings\Owner\My Documents\SOPs\"
'sets filename to value in "SOPName" bookmark & saves as
word doc
'ActiveDocument.SaveAs FileName:=strFileNM,
fileformat:=wdWordDocument
With Dialogs(wdDialogFileSummaryInfo)
.Title = strFileNM
.Execute
End With
End Sub
Thanks! Tag: Macros seperate from doc? Tag: 42206
RichTextbox dead in Word2003
I have a UserForm in Word VBA that is using a RichTextBox. When we try to
deploy this in Word2003, we find that the control is missing. If we try to
insert one, we get the message "The subject is not trusted for the specified
action." OK - what has Microsoft wrought now, and how do we get a
RichtextBox to show up in Word2003? Tag: Macros seperate from doc? Tag: 42204
Section number
Please help if possible.
Can someone supply me with VBA code that will tell me
what document section my blinking cursor is currently in?
Thanks in advance. Tag: Macros seperate from doc? Tag: 42194
Printing on smaller paper
I have been trying to print some party invitations on paper that is 5 1/2" x 8 1/2". I load the paper tray as instructed with the paper to the right side of the tray. Then I change the print preferences to 5 x 8 which is the closest size of my paper. But it still prints as though I'm printing on 8 1/2 x 11. I spent 30 minutes on the phone to the printer manufacturer, and we tried everything there was to try. They say its not the printer. Any ideas? Tag: Macros seperate from doc? Tag: 42190
Programmatically create PostScript files
Hello, please help me if you can.
Does anyone have example code on how to convert Word
files to Acrobat Post Script files using Word XP with
Windows 2000 and Adobe Acrobat 6.0?
Your example code would be most appreciated. Thanks in
advance. Tag: Macros seperate from doc? Tag: 42186
using templates
I am stuck on how to get my template to "run." I have fill in fields, etc in a 1 p template and I don't know how to make the system ask the user for input.
In Word Perfect, I used merge to a form document and I imagine it is similar here, but I can't figure it out....
help, please. Tag: Macros seperate from doc? Tag: 42164
Word 2000: Call a subroutine dynamically with VBA
I would like to call a subroutine dynamically based on a string that I am
building. I cannot seem to get the syntax to work. I have a listbox with
over 100 items in it, and each item within the listbox calls it's own
subroutine. With a simple string variable, I'd like to read the value
selected from the listbox and call it's subroutine, which is the same name.
Some very simple sample code is below:
Old Code Method:
Select Case Me.listItemList.Text
Case "Sub1"
Sub1_Proc
Case "Sub2"
Sub2_Proc
Case "Sub3"
Sub3_Proc
Case "Sub4"
Sub4_Proc
etc...will continue up past 100 with the same logic
End Select
New Code:
I would like to just reference the listbox and append "_Proc" to the end and
then call that subroutine, something like below:
Dim sProc as string
sProc = Me.listItemList.Text & "_Proc"
Call sProc Tag: Macros seperate from doc? Tag: 42152
Copy a page as a picture
Please help!
Is there a way to copy the page header and footer along
with the entire formatted contents of a page?
My objective is to make an exact copy of the page the way
it would look printed only copied to a new document as a
picture.
Your example code would be most appreciated. Thanks in
advance. Tag: Macros seperate from doc? Tag: 42151
Current Header and Footer Text
Is there a way to find out what the text is in the header and footer for the
page you are currently on?
TIA - Jeffrey. Tag: Macros seperate from doc? Tag: 42148
how to delete specific page breaks via vba
I have 400 + large documents that were genereated automatically. They
all have several extra page breaks at specific locations that are
causing blank pages. I already have code that loops a list and opens
each report in turn. I'd like to programmaticlly remove the specific
page breaks. It would take quite awhile to regenerate the docuemnts, so
I am hoping that programmatically modifying them will be faster. I'm
pretty good with Access VBA and VB, but not so familiar with Word and
its manipulation.
I have a bookmark I can go to which is after the pagebreak.
I want to step backwards to the 2nd preceeding page break and remove it.
Any suggestions for doing this? Thus far I have:
Selection.GoTo what:=wdGoToBookmark, Name:="SectionIV_TOC"
Selection.GoToPrevious wdGoToPage
Selection.GoToPrevious wdGoToPage 'this puts me on the page that has the
pagebreak at the bottom that I want to remove
How to select/move to the page break and delete it?
Thanks,
Tom Tag: Macros seperate from doc? Tag: 42146
Combo_Box/List_Box Populating
I have created a form which uses Drop-Down lists (Combo or list box) and am trying to find a way to populate the list with selections for the user. I know in VB you can uses Additem but the word document control does not seem to have the same functionality. Any help that can be provided would be greeatly appreciated. Tag: Macros seperate from doc? Tag: 42139
Word 2000: Minimize/Maximize button on a Form
I created a user form in Word 2000, and cannot find a property of the form
such as "MinMax Buttons" (like in Access) to have the form display the
Min/Max Button, rather than just having the "x" close button, which seems to
be the default of a Word Form.
How can I display these buttons? Tag: Macros seperate from doc? Tag: 42135
Negative number replaced with parentheses
Hi
I have a selection of text mostly in a table, but some in free text, that I
would like to replace all negative numbers (eg -99.24) with () so it would
read (99.24).
Can anyone help me please? I'll searched google and found nothing that
helps me. Can it be done using the find/replace dialog? Or is it a VBA
macro?
I'd prefer macro!
Thanks very much for your help Tag: Macros seperate from doc? Tag: 42134
VBA replace paste command with Paste Special option
Hello,
I would be grateful for help with this problem.
I would like a VBA macro to replace my default paste command with the
Paste Special option to paste as Unformatted Unicode Text. I want this
mascro, which I have recorded below, to globally replace all calls to
regular paste in the way that, for example, the FileNew() command can
be replaced.
How do I do this?
Thanks,
Enda
Sub PasteAsUnformattedUniCode()
'
' Macro1 Macro
' Macro recorded 01/12/2003 by Enda Ridge
'
Selection.PasteSpecial Link:=False, DataType:=20,
Placement:=wdInLine, _
DisplayAsIcon:=False
End Sub Tag: Macros seperate from doc? Tag: 42129
Selecting all text encompassed by a bookmark
Does anyone know how to create a macro that would select
all of the text that is contained in a bookmark (e.g.,
assume that I've bookmarked several paragraphs
as "Harvey"). How could I get a macro to select all of
the text bookmarked as "Harvey"?
I'd be pleased to pay someone for the answer.
Kindest regards,
Marc Tag: Macros seperate from doc? Tag: 42122
Help with "On Error"
I thought I understood "On Error" but I'm thinking that I got it
wrong.
Can someone point me to a clear description of "On Error" and
"Resume?"
I may be confused:
--------------
If I'm calling a single function and want to simply go to the next
statement in case of an error, I can write:
Private Sub MySub.
On Error Resume Next
'some call like Open a file
'other code that will be executed regardless of errors
End Sub
----------------
If i'm calling a bunch of potentially error-causing functions, I
thought I could install an error handler and then simply drop out of
my routine, like this:
Private Sub MySub2
On Error Goto ErrHandler
'some system call
'some code
'another system call
'more code
Exit Sub
ErrHandler:
MsgBox "Got an Error"
Exit Sub
But in reading Word 2003's help, it sounded like you have to have a
Resume statement or the error handler will stay alive, which I don't
want. Does exiting the subroutine terminate the error handler? If not,
how do I terminate without resuming immediately after the offending
call? Tag: Macros seperate from doc? Tag: 42121
AutoOpen dilemma
I have a developed a form that is downloaded each time a
customer (many and varied) needs to use it from the
Internet.
The AutoOpen sub (code below)is located in the
ThisDocument module and does various things when the form
is first opened.
Public Sub AutoOpen()
On Error Resume Next
ActiveWindow.View.ShowHiddenText = True ' shows the
hidden text to the user. This text will not print
'Application.EnableCancelKey =
wdCancelDisabled 'disables the ability for a user to break
the macro
Application.CommandBars("Update Details").Visible =
True 'displays the update details toolbar. This calls the
updetails procedure afeter user has filled in all details
Application.CommandBars("Update Details").Position =
msoBarFloating 'Positions toolbar as floating
Set BMRange = ActiveDocument.Bookmarks
("bkRentorFin").Range 'sets a range for the bookmark
If BMRange.Text = "" Then 'if there is no data in the
above bookmark it means this is a new document and need to
open user form
Set BMRange = Nothing 'makes sure the range is set
back to nothing
frmSelOpt.Show 'shows form
End If
ActiveDocument.FormFields
("bkFullName").Select 'selects first field on form
ActiveWindow.View = wdPageView 'ensures page layout
view
End Sub
My dilemma is this, if a user selects the "open" option
when downloading off the Internet the frmselopt.show does
not load. Also if the form is saved as a template and a
user selects it via File New, again frmselopt.show does
not load. It is almost as if someone is pressing the
Shift key when opening the form. Eveything else in the
procedure works fine. Another oddity when opening from the
Internet is that if the "Browse in Same Window" option is
checked within file types under Explorer the
frmselopt.show works fine. It also works without a
problem when opening from a normal doc.
Curiously as well the line Application.CommandBars("Update
Details").Position = msoBarFloating seems to be ignored
when opening from a template. It places the tool bar in
the last opened position (docked or undocked).
The form was written in word 97 but works well in other
versions.
Your help will be most appreciated
Greg Mc Tag: Macros seperate from doc? Tag: 42117
VBA code to Parse Word line
Hi,
I'm new to using VBA and am struggling with being able to parse a line
so I can use part of that information in the filename.
What I have are a bunch of Word files (these are doctor's patient
notes) that I need to do two things to:
1.) I need to split these files into individual files.
2.) I need the resulting filename to be have the "MRN number" "Patient
Name" "Date of visit" for the filename. (all of this information is
contained within the first three lines of these files)
For example, each file has the date as the filename and contains every
patient seen by the doctor on that date. I need this to be split so
each patient has their own file with the filename to be similar to:
'1111111 plaintom 113003.doc' and stored in a specific folder.
I have VBA code to split the files into individual patient files but
the filename is 'newdocumentx.doc' where x is a number.
Here is an example of the first three lines in each file:
CLINIC NOTE
PATIENT: LastName, FirstName CLINIC: 1234567
Doctor's Name, M.D. DATE OF VISIT: 5/30/03
Any help would be appreciated. Feel free to email me any suggestions.
Thanks,
plaintom Tag: Macros seperate from doc? Tag: 42103
Hello again!
Is there a way to keep a bunch of sets of macros that all
can go with one document and bind them together
programatically as needed? Thanks!
"Paul" <paulcaponetti@insurancedecisions.com> wrote in message
news:08f401c3b9cb$f0aaa240$a001280a@phx.gbl...
> Hello again!
>
> Is there a way to keep a bunch of sets of macros that all
> can go with one document and bind them together
> programatically as needed? Thanks!
>
> -Paul