Is it possible to write a wizard in VBA
I'd like to use VBA to write a wizard that handles a series of conditionals.
If this then display that; with next and previous capability. Is this
possible in VBA please?
TIA
Philip Tag: Run Macro automatically when files get open Tag: 98038
Search for textboxes
I recently moved a text box around in a word file and somehow it
disappeared. Can I ask Word to search for text boxes in a document via
VBA?
Help is appreciated. Thank you very much in advance.
Regards,
Andreas Tag: Run Macro automatically when files get open Tag: 98027
Convert INCLUDEPICTURE text strings to Word fields with curly braces around the text string
Hi everyone
>From a Filemaker database, I produce a Word document with exam
questions.
Some of the questions have images (diagrams). A text reference for
each image arrives in the Word document as a paragraph, with the
content required for a linked picture field. For example:
INCLUDEPICTURE "http://www.homepage.mac.com/itraining/iQ/24487.jpg
What I need is a macro to run through the document and convert the
INCLUDEPICTURE text string to a proper field, so the image is viewable
in Word. I am hopeless at VBA and have been unable to nail this with
my very limited Macro skills. Basically I need the opening and closing
"curly braces" to encompass the text string. Three examples are shown
below with live images that are accessible via a web browser:
Question 10
INCLUDEPICTURE "http://www.homepage.mac.com/itraining/iQ/24487.jpg"
Question 11
INCLUDEPICTURE "http://www.homepage.mac.com/itraining/iQ/24405.jpg"
Question 12
INCLUDEPICTURE "http://www.homepage.mac.com/itraining/iQ/22031.gif"
Any help would be greatly appreciated.
Thanks in advance.
Michael Richards
Brisbane (Australia) Tag: Run Macro automatically when files get open Tag: 98025
Text replacement
I have the following macro that finds the word â??Orderâ?? and changes it to all
caps and bold in the whole document. How do I change it to just replace it in
my ActiveDocument.Styles "Heading 1", "Heading 2", "Heading 3" and "Heading
4"?
Dim SearchRange As Range
Set SearchRange = ActiveDocument.Range
With SearchRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Format = True
.Wrap = wdFindContinue
.Replacement.Font.Bold = True
.Text = "Order"
.Replacement.Text = "ORDER"
.Execute Replace:=wdReplaceAll
End With Tag: Run Macro automatically when files get open Tag: 98023
Convert Table to OLE Word Document
Hello all,
I've got a VBA function that attempts to take a word table, select it,
cut it, and then create a Word OLE object where the table used to be,
then pastes the table into the Word OLE. I need this for a program I
work with that doesn't play nice with Word tables.
The code is below, and it works in Word 2003, but it will not work for
all tables in a larger document. I'm not sure why, and was wondering
if anyone had any ideas.
Thanks in advance!
Sub ConvertTablesToOLE()
'
'Move to top of document
Selection.GoTo What:=wdGoToPage, which:=wdGoToFirst
'Get count of tables
Dim tCount As Integer
Dim i As Integer
tCount = ActiveDocument.Tables.Count
i = 1
While i <= tCount
Selection.GoTo What:=wdGoToTable, which:=wdGoToNext 'go to first cell
of next table
Selection.MoveUp Count:=1
Selection.EndKey
Selection.TypeParagraph
Selection.MoveDown Count:=1
Selection.Tables(1).Range.Select
Selection.Cut
Selection.MoveUp Count:=1
'Create OLE, paste into it
Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8",
FileName _
:="", LinkToFile:=False, DisplayAsIcon:=False
ActiveWindow.Selection.Paste
ActiveWindow.Close
i = i + 1
tCount = ActiveDocument.Tables.Count 'We now have one less table, so
tCount gets updated
Wend
End Sub Tag: Run Macro automatically when files get open Tag: 98018
Auto-Prompts for Form
I have a fax cover sheet that I created using Word 2003. I want to set up
prompts that would prompt the user with a dialog bog and then he/she would
fill in the appropriate information and then it would populate the
corresponding portion of the form. Does anyone know where I can find a
tutorial for this task?
Thank you in advance, Karen Tag: Run Macro automatically when files get open Tag: 98013
Saving data from forms created in 2003 in 2007 version
In 2003 - you could extract data from forms using requesting to "save data
only" and then save the file as a plain text document - Data was saved and
separated by commas for easy export to other programs - I can NOT seem to get
this to work in the 2007 version - Any assistance would be greatly
appreciated. Thanks Tag: Run Macro automatically when files get open Tag: 98008
Skip Compile
Hello
OS: Windows XP
App:Word XP
Can I mark a section of VBA that will not be compiled?
Why? I want to include Word 2003 Compatibility Options in a Word 2002 Tool.
[Application.Version] will determine what code is run. Ideally
if Application.Version = 11 then
Compatilitity = 2002
ElseIf Application.Version = 12
Compatilitity = 2003
etc.
Any assistance will be greatly appreciated.
Regards
Mike Tag: Run Macro automatically when files get open Tag: 97989
regexp question
hi all
it's me again
In my vba program, I've created an new regexp called "reg"
the program will match the first paragraph in the active doc using the
reg.test
the program is how should I write the pattern to match "Chapter X"
I try the pattern "Chapter[ ][0-9]"
but it will also match a line like "Chapter 3342545435342543543543"
how should I tell regexp that it's end line??
I've try another like pattern "Chapter[ ][0-9]\n" , pattern "Chapter[
][0-9]^13"
but they cant match anything
many thanks Tag: Run Macro automatically when files get open Tag: 97985
Highlight Numbering
In WordPerfect we had the ability to highlight our procedure numbering when
we would make a minor change to it. An example would as follows:
1.0 Procedure 1
1.1 This procedure tells...
The 1.1 could be highlighted in Yellow if there was a minor change to the
text in that step. 1.0 is Heading 1, 1.1 is Heading 2 and so on. Is there a
way to do this in Word? Tag: Run Macro automatically when files get open Tag: 97977
Password dialog interferes with auto open macro
Hi,
I'm getting a problem that I believe is caused by a document's
password dialog. When I try to open the doc, I get the password
box and I get an error dialog saying the requested command could
not be performed because a dialog box is open.
Then, when I enter the doc, the macro executes twice, rather than
the once it should.
The macro in question simply goes to the end of the file and
inserts some blank paragraphs and the date or time. Now it does
that twice.
This didn't happen before I recently reinstalled Windows on a
reformat.
I suppose the way around this is to make the macro wait on the
password box or file painting. Or maybe someone knows a more root
solution.
Thanks for any input.
Paul
--
Using Office 2003 on Windows XP Home Tag: Run Macro automatically when files get open Tag: 97975
"corrupt" normal.dot
I recently installed Office2003Pro to replace Office97Pro on a Dell Dimension
4550 P4 2.5GHz computer running WinXPHomeSP1. The normal.dot file from
Word97 contained several macros that I can no longer use because I am no
longer with my former employer; the macros I am particularly these were
primarily macros to print on different LAN printers.
I have tried to remove these macros and have ended up with alternative
versions of normal.dot listed in the project pane when I switch to VB. When
I try to view these, I get the following message: Project Locked Project is
Unviewable. In addition, it will note allow me to delete these projects.
How can I force it to delete these unwanted projects??
I have copied and pasted a a "fresh" copy of normal.dot from another
(laptop) computer, but when I launch Word2003 on my desktop, I still get the
same VB page!!??
Thanks for your help. Tag: Run Macro automatically when files get open Tag: 97973
Err sending WD emailthru XL VBA-F8 OK, F5 not??
I'm using the following code in Excel VBA to create a Word doc, paste
in an Excel range copied as Picture, and save and send the doc as an
attachment. Because of our email system, it must go as an attachment.
When I step through with F8, everything is fine. When I use F5,
though, I get down to the PageSetup lines and get this error:
Run Time Error 462
The remote server machine does not exist or is unavailable.
If anyone has any suggestions or a better method, I would appreciate
all input.
Thank you.
Ed
(PS - Yes, a real email address was used in the test and went through
fine - with F8, that is.)
**********************************
Sub SendUpdate()
Dim wb As Workbook
Dim wk As Worksheet
Dim rng As Range
Dim x As Long, y As Long
Set wb = ActiveWorkbook
Set wk = wb.Sheets(1)
y = wk.Range("E65536").End(xlUp).Row
x = 20
Do
x = x + 1
wk.Range("G" & x).Select
If wk.Range("G" & x).Text <> "" Then Exit Do
Loop
ActiveWindow.ScrollRow = x
wk.Range("A16:J" & y).Select
Set rng = Selection
rng.CopyPicture
Dim WD As Word.Application
Dim doc As Word.Document
Dim WDrng As Word.Range
Set WD = New Word.Application
Set doc = WD.Documents.Add
doc.ActiveWindow.Visible = True
With doc.PageSetup
.Orientation = wdOrientLandscape
.TopMargin = InchesToPoints(0.75)
.BottomMargin = InchesToPoints(0.75)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
End With
doc.Content = "These due as of " & _
Format(Date, "dd-mmm-yy") & "; " & _
Format(Time, "hhmm") & " MST" & vbCrLf & vbCrLf
Set WDrng = doc.Paragraphs(doc.Paragraphs.Count).Range
WDrng.Paste
doc.SaveAs "C:\test.doc"
' Turn off spell check to avoid errors
doc.SpellingChecked = True
doc.HasRoutingSlip = True
With doc.RoutingSlip
.Subject = "Update"
.message = "Here is the current status."
.AddRecipient "me@notarealaddress.com"
.Delivery = wdAllAtOnce
End With
doc.Route
doc.Save
doc.Close
WD.Quit
wk.Range("C21").Select
End Sub Tag: Run Macro automatically when files get open Tag: 97968
Selection.Find.Found returns true after all items have been found
Hi,
We recently migrated from Word 2000 to Word 2003. We have a ton of VBA code
that we use in house and are finding some issues between the two versions.
We have code that looks through a document and finds italic, bold, etc. and
wraps the text with codes similar to HTML (we're coding for InDesign and
Ventura)
When running a coding macro to tag italic formatting on a document that has
tables I found that Selection.Find.Found returns true, and the macro
continues to run, even though we've found and tagged all the italic.
'These are the tags we're adding for italic
startcode$ = "<I>"
endocde$ = "<I*>"
'First I set up the search:
With Selection.Find
.ClearFormatting
.Font.Italic = True
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
'Then I execute the search
Selection.Find.execute
While Selection.Find.Found
ActiveDocument.UndoClear
Selection.MoveLeft wdCharacter, 1 'start of the italic
string
Selection.TypeText startcode$ 'add the startcode
If Len(startcode$) <> 0 Then
'go back over the startcode and set it to default
para font
Selection.MoveLeft wdCharacter, Len(startcode$),
wdExtend
Selection.Style = "Default Paragraph Font"
Selection.MoveRight wdCharacter, 1
'we're back at the start of the italic string
Selection.Find.Execute
'puts the cursor at the end of the string
Selection.MoveRight wdCharacter, 1
'we're at the end of the italic string
Selection.TypeText Text:=endcode$ 'add the
end code
If Len(endcode$) <> 0 Then
'swipe the end code and set it to default para
Selection.MoveLeft wdCharacter, Len(endcode$),
wdExtend
Selection.Style = "Default Paragraph Font"
Selection.MoveRight wdCharacter, 1
'we're at the end of the endcode, ready to look for
more italic
End If
Selection.Find.Execute
'when we hit the last of the italic Selection.Find in
Word 2000, selection.find.found = false and we exit the loop, but in 2003
it's true, but when the search executes again the cursor stays put and keeps
on typing startcode$ and endcode$ over and over as infinitum.
Wend
I can't turn off the italic (what if it's bold and italic, then I need to
come back and do bold.)
If I run this on a document with no tables it works fine.
Any help would be most appreciated!!
Thanks in advance,
Steven Lee
Vaporloop - Technology Solutions for Small Businesses Tag: Run Macro automatically when files get open Tag: 97965
How to add the data entered in a userform into a Text Form field
Hi,
I am very new to VBA, and word macros ( learning with the help of this forum
and Diane Chapman's tutorials).
I created a userform and want to populate the contents of a text Form field
on the word form with data entered in the userform.
How do I do it?
Essentially how do I append the values to the textForm field from the
userform?
Plz let me know if I need to explain what I am trying to do mor eclearly,
Thanks for your help
Sujit Tag: Run Macro automatically when files get open Tag: 97964
Background Color and Normal.dot
Greetings,
With the addition of the background color property I have found that setting
the background to dark and the font color to light makes reading much easier
on the eyes. Unfortunately, I am a little on the lazy side so I wish to have
Word (2007) do this automatically everytime I open or create a new document.
I figured that starting with new would be easiest, so in Normal.dot>New
Module I put an AutoNew macro that changed the bakground color and text to my
liking. It works when executed from the immediate window, but not on
loading. I am at a bit of a loss. Isn't the AutoNew event handler supposed
to execute when a new document is created using the selected (In this case
Normal.dot) template?
Cory Tag: Run Macro automatically when files get open Tag: 97955
A Global Variable Over Multiple Modules
I have a set of macros in multiple modules and would like to set a global
variable to be used by all these modules. If I define a global variable
within a module, all the macros in that module can see it but other modules
can't see it. How can I define a variable that can be used across multiple
modules? Tag: Run Macro automatically when files get open Tag: 97954
Limit a CommandBar Button Availability in Word
I have added a commandbar button to my Word document and it works. However,
I want my button only visible in a subset of my open Word windows. How can
I turn the button visible for one group of Word windows and invisible for
others? I have tried using the WindowActivate and WindowDeactivate. The
deactivate does turn it off when I leave the window, but the Activate turns
it on whenever I go to a different Word window.
Thanks for any help.
Private Sub AppEventHandler_WindowActivate(ByVal Doc As Document, ByVal Wn
As Window)
Dim oMenuBar As CommandBar
Dim I As Integer
Set oMenuBar = CommandBars.Item("Standard")
For I = 1 To oMenuBar.Controls.Count
If I > 28 Then
I = I
End If
If oMenuBar.Controls(I).Caption = "&" + Hdr Then '"&MyGoTo" Then
'oMenuBar.Controls(I).Delete
oMenuBar.Controls(I).Visible = True
Exit For
End If
Next I
End Sub
Private Sub AppEventHandler_WindowDeactivate(ByVal Doc As Document, ByVal Wn
As Window)
Dim oMenuBar As CommandBar
Dim I As Integer
Set oMenuBar = CommandBars.Item("Standard")
For I = 1 To oMenuBar.Controls.Count
If I > 28 Then
I = I
End If
If oMenuBar.Controls(I).Caption = "&" + Hdr Then '"&MyGoTo" Then
'oMenuBar.Controls(I).Delete
oMenuBar.Controls(I).Visible = False
Exit For
End If
Next I
End Sub Tag: Run Macro automatically when files get open Tag: 97952
Using prior version self-cert Digital Certificates in Office 2007
We have a number of "applets" that use Word and Excel (VBA and macros) to
function. These applets were originally designed in Office 2000 and 2003
using the self-certification tool included with those versions to sign them
for use in higher security environments where macro security is enabled.
They currently function in those environments without error or issue.
We are currently setting up our first Vista Workstation (running Ultimate
32-bit) and have discovered that Office 2007 treats our self-certified
applets differently than prior versions. Via the official Office website, we
learned that if macro security is enabled in Office, our self-certified
applets can only run macros if the digital certificate is added to the
Personal certificates folder. When we install our certificate via the
facility through Office 2007, it is placed in the "Intermediate Certification
Authorities" folder, not Personal. Exporting the certificate from the
"Intermediate" folder and importing it into the Personal folder results in a
"certificate imported successfully" message. However, the certificate does
not actually appear in the Personal folder and macros are not enabled on the
applets when executed.
Finally, we've found that creating a digital certificate using the
self-certification tool included with Office 2007 does allow us to import the
resulting cert file into the Personal certificates folder. Is it correct
that we will have to re-open and re-sign all of our self-certified applets
within Office 2007 for macros to be enabled properly? If so, what of our
clients that are using older versions of Office for which the applets were
originally designed? Is there any backwards compatibility between Office
2007 self-cert digital certificates and older versions of Office? Will we
have to maintain two different versions of the applets with two different
self-cert digital certificates?
Any help or information would be greatly appreciated.
Thanks,
Neil Dittmar
Software Developer
Aurora Information Systems Tag: Run Macro automatically when files get open Tag: 97949
This document failed to print message
Hi folks,
We've got a printer that gets jobs that can be hundreds of letters to
customers. When the printer runs out of paper, it will pop a message
up on the print server that reads, "This document failed to print".
Yet when we put more paper in, it seems to continue where it left
off.
Is it possible that it actually will drop pages out of the print job?
Thanks,
Cole Tag: Run Macro automatically when files get open Tag: 97939
Importing HTML table into Word 2003
Hi,
Here's what I'm trying to do. I have several JSP pages that creates HTML
tables as output. I use Document.Open to pull this HTML table into a
temporary word document. After that I use InsertFile to import that temporary
word document into the actual document I'm working on (I do this to prevent
memory issues on some of my larger tables).
Anyway, the problem I'm facing is, if one of the cells in the table has
either a greater than (>) or less than (<) symbol, the text gets truncated
from that character onwards. For example, if the cell text is:
Fever (in the absence of neutropenia, where neutropenia is defined as ANC
<1.0 x 10e9/L)
What gets imported into word is:
Fever (in the absence of neutropenia, where neutropenia is defined as ANC
Why is that? Why am I loosing the < character and everything after it? Is
there a way I can circumvent this? Is there a Word Patch? I'm not an expert
VBA programmer. This does not happen if I call the JSP page outside in
Internet Explorer. It opens up fine and displays all the text but in Word I'm
loosing half of the text.
Any help is greatly appreciated,
Thanks
Alex Tag: Run Macro automatically when files get open Tag: 97938
Create RTF file in VBA to include formatting?
Howdy- I searched this group for possible answers, but couldn't find
relevant hits.
My company uses an MS Excel file to collect information about labor
elements in a proposal response. Part of this process is to generate a
printable summary of that information. Excel can do the job, but I'm
sure I can do it better if I create an RTF file in VBA and write
summary data to it, then save it as an RTF to open in Word.
I've written the code to generate the RTF file from Excel. My question
is: can I include commands in my code that instruct Word to use a
particular font, headers, footers, etc.? Is it possible to write Excel
VBA code to generate a .DOC file directly that would include
appropriate formatting?
I'm experienced with Excel VBA and have written some Word VBA code,
and I'd appreciate your thoughts- is there a site I can visit to get
smart on this in a hurry?
Thanks,
Dave O Tag: Run Macro automatically when files get open Tag: 97937
Rearranging Table Columns
I have been playing around with some code to rearrange the columns of
a table.
E.g. existing data in a five column table
GRID NAME A B C D
1 2 3 4
Move column 5 before column 3. Then end result:
GRID NAME A D C B
1 4 3 2
I know (or think I know that you can't set a range = to a column so I
figured the best approach would be to write the data from the source
column (column 5) to an array. Add a new column before column 3.
Write the array results into the new column 3 and then delete the
source columne (now column 5).
Here is the basic code (stripped of error handling, etc.):
Sub ScrachMacroII()
Dim bProcess As Boolean
Dim myArray1() As String
Dim oCol1 As Long
Dim oCol2 As Long
Dim oTbl As Word.Table
Dim i As Long
Dim pStr1 As String
Dim newCol As Column
Dim lngLS As Long
bProcess = True
Do While bProcess
oCol1 = InputBox("Move column: ", "Source Column")
oCol2 = InputBox("Before column: ", "New Location")
On Error GoTo 0
For Each oTbl In ActiveDocument.Tables
If InStr(oTbl.Cell(1, 1).Range.Text, "GRID NAME") <> 0 Then
i = oTbl.Rows.Count
ReDim myArray1(i)
For i = 1 To oTbl.Rows.Count
pStr1 = oTbl.Cell(i, oCol1).Range.Text
myArray1(i - 1) = Left(pStr1, Len(pStr1) - 2)
Next i
Set newCol = oTbl.Columns.Add(BeforeColumn:=oTbl.Columns(oCol2))
lngLS = newCol.Next.Borders(wdBorderRight).LineStyle
newCol.Borders(wdBorderRight).LineStyle = lngLS
For i = 1 To oTbl.Rows.Count
oTbl.Cell(i, oCol2).Range.Text = myArray1(i - 1)
Next i
oTbl.Columns(oCol1 + 1).Delete
End If
Next oTbl
If MsgBox("Do you want to continue with another move?", _
vbQuestion + vbYesNo, "Continue?") = vbNo Then
bProcess = False
End If
Loop
Exit Sub
End Sub
I am just wondering if I have attempted to reinvent the wheel and if
there is a better, more simplified approach.
Thanks. Tag: Run Macro automatically when files get open Tag: 97935
A section that appears or disappears
Hey all,
This sounds so simple, but is complete doing my head in!
I have a word VBA file, that on open, a form pops up and the user
fills in the details.
It then populates 2 files with said information, and copys important
information to the clipboard - thus saving a lot of time.
I'm using textboxes in tables on the word file and textboxes on the
userform.
However, there is a section that may not apply to everybody, and I
don't want the user to have to delete it if it doesn't apply - I'd
like my program to do that for him. If this section isn't applicable
to the specific client, I'd like to be able to remove it with a check
box - and for the rest of the file to "move up" as to not leave a
massive space in the document.
Anyone know this, it sounds simple, but I can't figure it out!
Cheers,
Rich Tag: Run Macro automatically when files get open Tag: 97933
Autotext text and table, keep formatting
I've got a Table placeholder which has looks similar to this:
Table Title (specific paragraph style applied)
table here, one column, one row, character style applied
Source: (specific paragraph style applied)
I can't seem to get the formatting for the last line "Source" to keep it's
formatting. I've tried choosing the paragraph mark before and after the
text, but it just changes the "Source" line to Normal font (default).
Any suggestions from anyone?
/Under the gun.... Tag: Run Macro automatically when files get open Tag: 97930
MSXML2
Trying to write code that will write to an xmlfile and replace values for
DocType, LanguageCode and. The xml contains other xml tags as well but they
should not be overwritten. My example xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<GDAInfo>
<System>
<DocType>1</DocType>
<ActiveSection>senad</ActiveSection>
<LanguageCode>SE</LanguageCode>
<UseTitle>False</UseTitle>
<NatDirectNumber>08-</NatDirectNumber>
<IntDirectNumber>+46 8 </IntDirectNumber>
</System>
</GDAInfo>
Managed to load and get info from xml file but to write to a certain tag in
the xml file.
Public Sub LoadXml()
Set oXml = New MSXML2.DOMDocument
oXml.async = False
If Not oXml.Load(GetXmlFilename()) Then
MsgBox oXml.parseError.reason
Exit Sub
End If
End Sub Tag: Run Macro automatically when files get open Tag: 97929
How to open multiple instances of MSWord through VB
Hi
I want to open MS Word document through VB 6.0 and i am using
shellExecute API
sub command1_click()
Rtn = ShellExecute(frmName.hwnd, "Open", "C:\Program Files\Microsoft
Office\OFFICE11\WINWORD.EXE" , " C:\Program Files\Proj\sheets
\DocName.doc", "", 5)
end sub
when i click the command1 button then word document DocName.doc opens.
that's fine. again when i click the command1 button then same document
which was already opend is shown.But I want to to open multiple
instances of the same document. If i click command1 button 5 times
then 5 instances should open separately and then obviously close
separately. Our requirement is that 4 out of that 5 instances should
be read only ?
It should be noted that same API works fine for opening multiple
instances of MSExcel documents.
Regards
Imi Tag: Run Macro automatically when files get open Tag: 97921
Debug Clear
Hello
OS: Windows XP
Apps: Office XP
Does anyone know how to clear the immediate Window using VBA ie. 'Debug.clear'
Any suggestions would be appreciated. I understand that closing Word will
clear it but I am looking for a VBA option.
Regards
Mike Tag: Run Macro automatically when files get open Tag: 97920
Recording macros in Word 2007
I have begun using Word 2007, usually in compatibility mode. I find that when
I record a macro and assign to a keystroke combination, it only works in some
documents. Many of my macros are simply "assign a style" macro or something
equally simple just because I don't like to go to the mouse for repetitive
actions. Often, I get the "debug-cancel" message. When I recorded macros in
2003, they usually worked across all documents based on templates I had
created.
When I re-record a macro that is not working in the present document, it
asks if I want to replace the existing one with the same name. It clearly
knows the macro is there. Why won't it run in documents? Is there a
specification I can make when I record a macro so that it will be universal?
Thanks in advance. Tag: Run Macro automatically when files get open Tag: 97908
Macro that will create a new directory?
I'm trying to write a Word macro that will create a new directory on my C:
drive. Is this even possible? Tag: Run Macro automatically when files get open Tag: 97898
USPS Barcodes
I recently had need to send mail to an individual at USPS ZIP+4 address. I
addressed a single label using Word and printed it. I later had cause to use
the Merge feature to create multiple labels and happened to include in the
Excel database the same identical ZIP+4 address! I was very surprised to
find that the postal barcode it generated was DIFFERENT (in the last 16 bars
short/tall)! I then tried my own barcode (75248-3060) with the same
experiment and lo, it too generated two diferent barcodes! Anyone guess why? Tag: Run Macro automatically when files get open Tag: 97896
Testing for blank pasges in document
Hi,
Is there a way to loop through each page in a document to test if it is
blank (ignoring header/footer) and if it is blank to remove the page?
Thanks. Tag: Run Macro automatically when files get open Tag: 97880
Conditional Compilation
I am aware that there are no conditional compilation constants after
VBA6 to distinguish between versions of Word. I have also read items
like the following workarounds:
> What you can do is place all the office 2007-specific code into separate modules, If no code in that module is ever called when the template is used in Word 2003, then the template will run OK.
The problem I'm having is that either this doesn't work or I'm missing
something. I have a module called Word2003 that contains only the
following:
Sub TurnOffReading()
Options.AllowReadingMode = False
End Sub
I call it like this:
If Left(Application.Version, 2) >= "11" And
Left(System.OperatingSystem, 3) = "Win" Then
Word2003.TurnOffReading
End If
I still get the message "Compilation error in hidden module" when
running this in earlier versions of Word. Tag: Run Macro automatically when files get open Tag: 97877
Delete paragraphs in active document?
I have a collections letter that 1) thanks the recipient for verbal agreement
to payment plan in paragraph1 and then 2) askes the client to sign and return
a promissory note in paragrah 2.
I'd like to deleted paragraph 2, paragraph 10 (the enclosure line), and page
2 (the enclosure) if the author does not want the promissory note.
I've set up a form that has 3 buttons: Cancel, Letter Only, and
Letter+Promissory Note.
The Letter only button passes txt values to bookmarks, and I'd like it to
delete text as shown above. It's not ActiveDocument.Paragrah.2.Delete; it's
not anything I've tried so far. Please help, VBA masters!
If I'm going about this entirely wrong, I want to know. If I just need to
read a key webpage, I'll take a link. I've googled endlessly and can't find
it.
Thanks in advance!
Sandi Tag: Run Macro automatically when files get open Tag: 97875
Print Text Form Fields
I received this document that has Text Form Fields. These field have data
typed in. The problem is when I try to print this document then the form
fields
go blank. The data does not print. What is going on?
I want to print the data in the form fields. Any help is appreciated.
Robert Tag: Run Macro automatically when files get open Tag: 97874
Key bindings for commandbar pop-ups?
My template has a commandbar with buttons and pop-ups (menus). I've been
adding keybindings for the buttons by simply having the shortcut key call the
same macro the button calls.
Now, I'd like to add a keybinding that will open a pop-up (menu) on the
commandbar, just like pressing Alt-F opens the File menu in Word.
The desired behavior would be pressing Alt-something and having a pop-up on
my commandbar open, so that the user could use the arrow keys to go up and
down the menu. Pressing Enter would then select a command--all exactly like
the regular menus in Word.
Here's what I've been doing to assign keys to macros so far:
____________________
' first I set the CustomizationContext to my template, etc. then I do this:
With Application.KeyBindings
' "New Solution" is Alt-N
.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyN), _
KeyCategory:=wdKeyCategoryMacro, Command:="Nl1"
' etc.
_______________________
It seems like I could somehow put the pop-up into the Command argument--or
do I need to change the KeyCategory to wdKeyCategoryCommand as well?
Is this even possible?
Thanks in advance!
Ben Tag: Run Macro automatically when files get open Tag: 97873
VBA for opening a dialog box without losing focus on toolbar
I have successfully written a macro to open Document Properties dialog box so
users can enter repetitive data to populate fields throughout the body and
header/footer.
Sub ShowProperties()
'
'Shows the Properties Dialog Box
On Error Resume Next
WordBasic.FileProperties
On Error GoTo 0
' Macro recorded 10/4/2006 by Jack Feeman
'
End Sub
However, after entering in the (meta)data and clicking the OK button, the
dialog box closes and so does the custom toolbar that contains the button
that opened it. Even though clicking anywhere in the background brings it
back, we want a positive user experience and someone will always forget to
click to bring it back. If I manually open/close the dialog box, the custom
toolbar stays put. If I do the same thing via a custom button the toolbar and
if another window is open in the background it will become the focus when I
close the dialog box.
Anything I could add to the macro that will bring it back automatically upon
closing the dialog box?
The "Record new Macro" toolbar always disables itself if I try to change
tabs on the Document Properties dialog box or in any other way try to do
anything else in the dialog box except for opening it. If I click OK during
the recording of the macro, the "Record New Macro" toolbar will become
enabled again, but I do not want to close it since the user will not get a
chance to enter any data.
What I am trying to do in addition to opening the Document Properties dialog
for data entry; I wanted to select the Custom tab of the dialog box where all
the information to be entered is consolidated. If I click on the tab, it does
not select it and the "record New Macro" toolbar disables itself.
Thanks
Jack Tag: Run Macro automatically when files get open Tag: 97865
Menu Gets removed but not Toolbar Icon
I am facing a problem when after uninstalling my Macro's, the Menu gets
removed but not the Tool Bar Icon, it is happening only in Ms Word 2007. Note
that I am not doing anything in AutoExit or AutoClose. I am saving all my
changes in my own template and then deleting that template file on uninstall,
still that Icon is left behind.
Thanks in advance Tag: Run Macro automatically when files get open Tag: 97862
Define a custom RGB Colour using VBA
I recently wrote below (simple) macro which changes the row colour of
a table from blue to yellow. Is it possible to define a custom colour
such as RGB (17, 33, 55). And if this is possible, how do I have to
rewrite this macro.
Help is appreciated. Thank you very much in advance.
Regards,
Andreas
Sub ChangeShading()
Dim oRw As Row
For Each oRw In ActiveDocument.Tables(1).Rows
If oRw.Cells.Shading.BackgroundPatternColor = wdColorBlue Then
oRw.Cells.Shading.BackgroundPatternColorIndex = wdColorLightYellow
End If
Next
End Sub Tag: Run Macro automatically when files get open Tag: 97858
How can I set MS Word in MS Office 2003 to show fractions eg 2/3
My MS Word program is set to show the usual fractions as fractions on a split
line but when I type such fractions as 2/3rds or 4/5ths they do not show as
such. Tag: Run Macro automatically when files get open Tag: 97855
Assembly reference issue
Hi,
I am writing a C# plugin for a third party tool. Multiple versions of
the same tool can be installed on the client machine at any given
time.
Version 6 of this tool is managed code while version 5 is not.
The plugin is built on version 6 of the tool.
So, when the plugin is installed on a machine that has only version 6
of the tool, it works fine. As expected, it doesnt work if only
version 5 is installed.
The problem is, it is not working if both version 5 and 6 are
installed. How can I tell my plugin to use the file from version 6 of
the tool?
Regards,
Shilpa Tag: Run Macro automatically when files get open Tag: 97849
Create Control at runtime
Hi
Am I able to create controls (for example: combox box) at runtime?
if possible, how can I do it ?
Thanks Tag: Run Macro automatically when files get open Tag: 97848
Extended list view question
Hi
Have any1 here tried the "extended list view"
http://vcreations.net/product.asp?pid=1
How can I create combox within the list view?
I cant add item to the combox dropdown list
Thanks Tag: Run Macro automatically when files get open Tag: 97847
Change Width of Objects
I am using the following steps to copy a range of cells from an Excel
document and paste them into a Word doc.
Past Special > Link > Microsoft Office Excel Worksheet Object
Would someone be able to provide me with some VBA code that could be
used as a macro to automatically re-size all of these objects in Word
to a specified width?
Thank you,
William Tag: Run Macro automatically when files get open Tag: 97844
Disable and enable a document in vba issue?
Hi All,
I have a word template1 , and i write documents.add("path template2", false,
wdNewBlankDocument, false) code to create another document base on template 2
with visiable = false, achieve this by set the last parameter of
document.add() to false.
the questiosn here is how to reset the visible of new docuemnt to true.
Cheers
Nick Tag: Run Macro automatically when files get open Tag: 97843
protect variable from spell check?
I'd like to protect a patient's name from the spell checker. Patient's
name varies from document to document with each patient having a
personal single document file. Each patient's name appears multiple
times in the document.
Adding an ever-increasing number of patients' names to the custom
dictionary in an ongoing constantly updating fashion is unreasonable.
Is there a reasonable way to preclude spell checker from identifying
their names as misspellings? Perhaps I could automate copying the
patient's name into one of the document properties and any item in that
location would be protected from spell check? Using fields and/or
sections protected from spell check seems fraught with multiple
difficulties for many MS Word users.
Alternatively, an automated addition of patient's name to the custom
dictionary might work. ? perhaps something like the following to add to
"myNames.dic" where code has previously selected the patient's name.
Dim tempNam as string
tempNam = Selection.Text
Set myNames.doc =_
Application.CustomDictionaries.ActiveCustomDictionary
Dim d 'Create a variable
Set d = CreateObject(Scripting.Dictionary)
' Object.Add Key, Item
d.Add "a", "Athens" 'Add some keys and items
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
d.Add tempnam
or maybe something simpler?
"spell check but not check variable"
;)
tia,
Gil
http://www.TenSecondMedicalRecord.com Tag: Run Macro automatically when files get open Tag: 97832
Steps to write and activate macro in Word 2003
Folks,
Any step by step for adding a macro into a word 2003 document?
I want to read one Bookmark A and based on this value show in another field
a default value for Bookmark B or text field. Example: The dropdown value
selected is equal to text "NYC", the default value sould be text "SOHO". How
do I get SoHo to show up in Bookmark B or text field? Then if the dropdown
value is changed to "Boise" the default value in the other field would be
default to "Idaho".
thx. Tag: Run Macro automatically when files get open Tag: 97820
Dear Sir,
I have created macro name auto_open in word which finds & replaces text.
I wanted to run this macro at the time when file opens.
Re: Run Macro automatically when files get open by Graham
Graham
Sun Mar 18 03:19:48 CDT 2007
Remove the underscore from the macro name.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Rupesh wrote:
> Dear Sir,
>
> I have created macro name auto_open in word which finds & replaces
> text.
>
> I wanted to run this macro at the time when file opens.
>
> thnks
> rupesh.