show label dialog box
Hi,
I would like to create a macro that displays the
envelope/label dialog box, but on the label tab. (I have
created a custom envelope macro, and therefore don't need
the Word envelope feature.) Any help on the macro
language to show the label dialog box?
THANKS!
Kurt Tag: show label dialog box Tag: 53304
Macro to eliminate mutiple blank lines.
Hi, just wondering if anyone has made one already (Please
dont waste your time writing it unless you have it), I
need a macro that will go through a document and spot
places where there is more than one blank line between
lines with text and leave only one line. I'm looking for
a simple recursive function. I can write a big function
to do it but I think there is a simpler way I'm
unfamiliar with. NOTE: I tried lookign for consecutive
line breaks replacing them with one line break but that
didn't really work. Tag: show label dialog box Tag: 53301
Is it possible to do this using VBA in MS Word
Hi,
I am a newbie to MS Word Programming, I would like to know if VBA is
possible to do the following jobs for me:
1. When type a typo in word, the word will be underlined, is it possible
to do this using VBA?
2. When you right click the underlined word, a list of suggestions will
be shown, is it possible to program it using VBA?
Since I am just a newbie, I don't know if VBA can do this or not, if
this cannot be done using just VBA, pls point me to the right direction...
Thanks and hope for reply.
Regards,
Johnny Tag: show label dialog box Tag: 53297
Checkbox Macro on Exit
I've created a form template with "x" boxes. I'd like for
the "xed" box to become red in color when the user clicks
on it. I've tried assigning a macro to do this, but the
message I get upon use is that the macro cannot be
performed because the document is protected (which it
would be, being a form!)
Anybody have an idea for a work-around? (My experience w/
Visual Basic is minimal, but I think I can plug in a
macro.)
Thanks! Jenny Tag: show label dialog box Tag: 53296
2003 best Help for dim OOP-er
Does there appear to be some reason why this code returns a No.
4160, 'bad file name' error:
Set docCurrentDocument = Documents(strFileName)
or
Documents(strFileName).BuiltInDocumentProperties(wdPropertyAuthor)
where strFileName looks perfect, returned from:
strFileName = Application.FileSearch.FoundFiles(index)
?
--
Jim Shores Tag: show label dialog box Tag: 53294
Styles automatically renamed ...
Word XP
---------------
Problem:
Step 1:
- "Heading 1" is defined with certain formats
Step 2:
- User changed formats for "Heading 1"
- The text parts that were "Heading 1" are automatically
renamed to f.e. "Heading 1 + 11 pt" by Word
Step 3:
- I try to change formats for all text parts in the document
that were originally formated as "Heading 1". Because they
were renamed automatically, my changes do not affect those
text parts.
How can I get them back under control? Thanks for any help
Best Regards, George Tag: show label dialog box Tag: 53289
Opening a Web Page
I've got a word document that under certain conditions
opens then creates an internetexplorer.application then
immediately navigates to a web page, is there anyway of
maximizing the internet explorer window through the word
macro.
Help!!!
Stewart Tag: show label dialog box Tag: 53288
Removing Metadata
Greetings. I'm trying to find a way to automate the removal of metadata
(author info, etc.) from Word documents. Can someone recommend a good way to
proceed? Ideally I would be able to "clean" docs with a single click from
within Word, drop files onto an application icon, run the cleaner from the
context menu, or script the process for multiple files. Is VBA the best way
to accomplish this?
Many thanks in advance for any tips,
Michael Tag: show label dialog box Tag: 53287
Doc name and page # in header
I have a few hundred or so word doc's. I'd like a macro
to open each one and insert the document name and page
numbers (ie: NameOfDocument.doc page 1 of 5) into the
header. Then, save and close the file, open the next, etc.
This would take forever if done by hand. Any suggestions?
Thanks!
C Tag: show label dialog box Tag: 53278
Problem populating a formfield with multiline text from Userform.
I have a text form field called "bmAddress" and use a userform with a multiline text box to populate (ActiveDocument.FormFields("bmAddress").Result = userform.txtaddress).
For some reason when the information populates into form field Â? (a square) appears on every new line.
Â?Address 1
Â?Address 2
Â?Address 3
Â?Post Code
On Windows XP it displays as a space, so I can't use a find and replace to remove the squares.
Unfortunately i do need this to populate into a form field and not just a normal bookmark.
Appreciate any help.
Thanks
Caro Tag: show label dialog box Tag: 53264
Conditional compilation on Word version
Hi
anybody know how to get a conditional compilation based on the version
of word ?? This bit of code doesnt work but illustrates what i need
#if Val(Application.Version) > 8 Then ' 8 = Word97, 9 = Word2000
blahblah
#endif
Actually what i need is way of telling whether the Assistant(clippy) is
loaded that works in both Word97 and Word2000, unfortunately the
assistant appears to behaves slightly differently in each so i need
different code.
thanks
Dave Tag: show label dialog box Tag: 53262
Word as report engine??
Hi:
I'm new to word and am having some trouble figuring out how to create a report template of several pages and loading
data from my SQL Server database into the appropriate sections of my report. The report requires that individual
columns from individual records be used in specific portions of the report. There are often in excess of 20 records
used for a report.
I've tried the mailmerge which doesn't work because I must either select a form letter or a label.
Any help or suggestions greatly appreciated.
TIA,
Cathy Tag: show label dialog box Tag: 53260
Automating change link source in Word document
I created a master Word document, which has 115 links to a master Excel file. For each new client of mine, I need to save both the Word document and the Excel file under new names. This means that I have to change the links source manually for all 115 links. This becomes a rather tedious task, as I add new clients daily.
Can someone help me with a macro that will change the link source? I use Word 2002 and Excel 2002. Tag: show label dialog box Tag: 53256
Conversion of VBA script for Word95 to Word 2002
The following is a script I developed years ago for Word 95 - it still works
fine and is the reason my typist uses WORD 95 (no real need to upgrade).
However, as I need to go to ACCESS2002/03 - I am thinking of moving on to
WORD 2002/03 as well.
Am I better off staying with VB Script or will the new macros in the latest
versions of WORD be better?
___The code script basically collects the text from a group of letters
puts/archives it into one file of template "pcopy" tagging each with a date
and then saving the file with a name that includes the current date.
________
Dim wd,n
Dim fso, f, f1, fc, s,h,nn, y, m, d
dim sh, snn, sn, sy, sm, sd
Set wd = CreateObject("word.basic")
wd.FileNew ("pcopy")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("\\p266\c\my documents\practice letters\")
Set fc = f.Files
For Each f1 in fc
n=n+1
s = f1.name
wd.Insert Left(s, Len(s) - 4) + " .. " ' line16
wd.InsertDateTime "d MMM yy .. hh:mm:ss", 0
wd.ParaUp
wd.RightPara
wd.ParaDown
wd.InsertPara
wd.InsertFile "\\p266\c\my documents\practice letters\" + s, , , 0
wd.InsertBreak
Next
wd.editclear -1
y=datepart("yyyy",now)
m=datepart("m",now)
d=datepart("d",now)
h=datepart("h",now)
nn=datepart("n",now)
sy=right(formatnumber(y,0),2)
if m<10 then
sm="0"+ formatnumber(m,0)
else
sm=formatnumber(m,0)
end if
if d<10 then
sd="0"+ formatnumber(d,0)
else
sd=formatnumber(d,0)
end if
if h<10 then
sh="0"+ formatnumber(h,0)
else
sh=formatnumber(h,0)
end if
if nn<10 then
snn="0"+ formatnumber(nn,0)
else
snn=formatnumber(nn,0)
end if
if n<10 then
sn="0"+ formatnumber(n,0)
else
sn=formatnumber(n,0)
end if
wd.FileSaveAs "\\p266\c\my documents\archive\" + sy + sm + sd + "_" +
sh+snn + "_" + sn + ".doc"
wd.FilePrintSetup "Photocopier on Lexnet"
__________
--
John
jrg_REM_SPAM@bigpond.net.au Tag: show label dialog box Tag: 53245
Word & Excel MVP code problem
http://www.word.mvps.org/faqs/interdev/ControlXLFromWord.h
tm
I have been attempting to use this code on two PCs using
Office 2000 and a friend has tried on Office XP, but in
neither case was the code able to open Excel where it was
not already running, just open the named file when it was
already running. The code ran with no errors reporting,
but nothing actually happened whenExcel was not running.
The code was copied and pasted, with only the file
pathname being changed. I managed to select the Microsoft
Excel Object 9 ( 10 in XP) Library - although this option
was not present for selection in the references until the
code had run and failed at least once.
Is there a problem with this code? Tag: show label dialog box Tag: 53244
Document not displayed properly
I created a word template and the top half of the page is
2 columns wide - the bottom half of the page is a text
box and the document text is written over top of the text
box. The template executes a VBA macro that inserts the
text that the user enters into text boxes and places the
text at the appropriate bookmarks. When the VBA macro is
done and the document is displayed in normal view it
indicates where the column breaks are but it shows the
2nd column under the 1st in a single column width. If I
click View-Print Layout the document is shown correctly 2
columns wide with the text box below. I am using Word
2003. What is the best way to correct this?
Thanks Mike Tag: show label dialog box Tag: 53235
Damaged word files?
After a power outage and a corporate upgrade to word 2003
(we don't now which is responsible for al the problems) we have
problems with opening word files.
It sometimes takes up to 5 minutes to open a simple word file. When it
finally opens we save the content to a different word file (by hand).
Now the question is can this task be automated? We don't just want to
loop true al the files in VBA and do a save document. It must be some
kind of a copy al content and save that as a new document function but
how can we do this? What is the best way to select al of the content?
Thanks in advance.
Kevin Bronsdijk Tag: show label dialog box Tag: 53232
how to make a document password protected on closing
Hello - I hope this is the right forum. I am not a programmer but think I need a programmer's help for this. I would like a Word form to be password protected upon closing. This is to allow a survey result to remain confidential until opened by the correct person. Security level doesn't need to be very high. Is there a macro that can do this? thanks. Tag: show label dialog box Tag: 53231
FAQ - frequently asked questions - vba - Please Read Before Posting - unofficial
FAQ = Frequently Asked Questions - brief - vba - unofficial
This FAQ is posted weekly.- more or less
Please save us all some time by reading it before posting to the
news group.
This newsgroup is about VBA - Visual Basic for Applications -
which is the programming language for Word 97-2003 (macros).
There is a longer FAQ with more questions and links that is
regularly posted in the non-VBA Word newsgroups. You may want
to check that out as well.
--- BEFORE POSTING ANYTHING PLEASE READ THESE ---
http://www.mvps.org/word/FindHelp/Posting.htm
http://www.dts-l.org/goodpost.htm
Reading these articles will help you get a quick and meaningful
response to your question rather than just more questions for you.
It may keep your message from being screened or bounced.
A few basics, though:
(1) Be nice; everyone answering questions here is a volunteer.
(2) Post a question in only one newsgroup generally. If you
_have to_ post in more than one, post a _single_ message and
put both newsgroups in the header for that _single_ message.
(3) Do not attach anything to a message.
(4) The only really stupid question is the one you don't ask.
(5) Do not use your real email address unless you want spam.
(See bottom for sample.)
The reasons for the requests are spelled out on the web page.
A longer version of this FAQ is also on the Internet at
http://addbalance.com/word/index.htm
Newsgroup Archives:
http://groups.google.com/advanced_group_search
MVPs FAQ site: http://www.mvps.org/word/ To the extent
there is any "official" FAQ, this is it.
---
Also, before posting, you may want to look at the following
questions to see if yours is among them.
---------- ---------- ---------- ---------- ---------- ----------
1. I see a macro in a newsgroup I would like to try. How
do I add it to my template?
http://addbalance.com/word/macrosfromnewsgroup.htm or
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm
2. What are some good books for me to read about Word?
http://addbalance.com/word/wordbooks.htm and
http://www.mvps.org/word/Tutorials/BookRecommendations.htm
3. How can I run a macro automatically when a document opens,
closes, is created?
http://www.mvps.org/word/FAQs/MacrosVBA/DocumentEvents.htm
4. What is an MVP?
http://www.mvps.org/word/AboutMVPs/index.html and
http://addbalance.com/word/mvp.htm
5. I need to make a form to...
Userforms are custom dialog boxes written using vba.
If you want a fill-in-the-blanks form you want what Word
calls an online form. Look in Word's help for that,
and for more info on online forms follow the links at:
http://addbalance.com/word/wordwebresources.htm#Forms
especially Dian Chapman's series of articles
If you want a custom dialog box that you code with VBA commands
you want a UserForm. Take a look at:
http://www.mvps.org/word/FAQs/Userforms.htm
6. Where can I find more information on the Web?
http://addbalance.com/word/wordwebresources.htm#webvba
http://www.mvps.org/word/FAQs/MacrosVBA.htm
http://www.mvps.org/word/FAQs/Userforms.htm
http://www.mvps.org/word/FAQs/Customization.htm
http://www.mvps.org/word/FAQs/OfficeInterdev.htm
Comments / corrections / additions may be sent to
wordfaq@no.spam.addbalance.com. Remove no.spam from the
address. (This is a "proofed" email address, I hope.)
Posted 5 July 2004
Charles Kenyon (the editor) Tag: show label dialog box Tag: 53229
Macro to Wrap Selected Text with Brackets
Hi,
Is there a way to wrap pre-selected text with brackets using VBA? To
explain, the user types text (can be numbers, dates, one or more words),
selects the text to be wrapped with brackets and kicks off a macro to insert
open bracket at the beginning ([) and a closing bracket (]) at the end of
the selection.
Thanks in advance. Tag: show label dialog box Tag: 53224
Adding reference without UNC
When I use
"ActiveDocument.AttachedTemplate.VBProject.References.AddFromFile" and add a
reference to something like "X:\xxx\xxx.dot" it adds a reference to
"\\Servername\xxx\xxx.dot".
I have a global template started from the Word Startup directory. At the
beginning of my code I add a reference in the above mentioned way to be able
to access methods in my global module. When I now look in the Tools-Add Ins
dialog I now have two references to the same template (and double menu bars
from my template). One reference with UNC-path and one without.
I use Word 2003. In earlier Word versions it works fine
Does anyone have any idea how to get rid of these double references?
Is the only way to set the path to the Startup directory using UNC notation?
Thanks in advance,
Siim Tag: show label dialog box Tag: 53223
open Excel from Word 2000
I am sure I am probably missing something silly, but I
have copied code from the MVP site to open an instance of
excel where one is not already open. Unfortunatley I get
a "user type not defined" error when I try to run it.
What have I missed? (best point it out simply unless I
also missed it from the MVP site- it mentions adding a
reference, but not sure if th code is doing that or i was
supposed to have done something?)
Sub WorkOnAWorkbook()
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
'Dim oSheet As Excel.Worksheet
'Dim oRng As Excel.Range
Dim ExcelWasNotRunning As Boolean
Dim WorkbookToWorkOn As String
'specify the workbook to work on
WorkbookToWorkOn = "C:\CONTRACT\CONTRACTnew.xls"
'If Excel is running, get a handle on it; otherwise start
a new instance of Excel
On Error Resume Next
Set oXL = GetObject(, "Excel.Application")
If Err Then
ExcelWasNotRunning = True
Set oXL = New Excel.Application
End If
On Error GoTo Err_Handler
'If you want Excel to be visible, you could add the line:
oXL.Visible = True here; but your code will run faster if
you don't make it visible
'Open the workbook
Set oWB = oXL.Workbooks.Open(FileName:=WorkbookToWorkOn)
'Process each of the spreadsheets in the workbook
'For Each oSheet In oXL.ActiveWorkbook.Worksheets
'put guts of your code here
'get next sheet
'Next oSheet
If ExcelWasNotRunning Then
oXL.Quit
End If
'Make sure you release object references.
'Set oRng = Nothing
'Set oSheet = Nothing
Set oWB = Nothing
Set oXL = Nothing
'quit
Exit Sub
Err_Handler:
MsgBox WorkbookToWorkOn & " caused a problem. " &
Err.Description, vbCritical, _
"Error: " & Err.Number
If ExcelWasNotRunning Then
oXL.Quit
End If
End Sub Tag: show label dialog box Tag: 53220
VBA Macro for adding resized photos
Dear all
I would like to add a resized photo to a word document and have the
following code.
Unfortunately it fails!
Please can you help me with it!
Cheers
John P
North Yorkshire UK
Sub AddPicturefromdirectory()
If Selection.Information(wdWithInTable) Then
Dialogs(wdDialogInsertPicture).Show
With Selection.Cells(1).Range.InlineShapes(1)
.LockAspectRatio = msoTrue
.Width = InchesToPoints(1.4)
.Height = InchesToPoints(1.8)
.Range.Copy linktofile:=False, savewithdocument:=True
End With
Else
' Error Message and Quit
End If
End Sub Tag: show label dialog box Tag: 53213
emailing saved doc from the template using non-microsoft/web clien
Hi all,
Template is ready now! But one more question!
I want to add a "send" button to this template, so that when clicked, a save dialog box pops up to save as a file (.doc) on a local hard-drive in a pre-determined folder for my records, and simultaneously email this file (.doc) only (without "send" button) to a my manager (to a specified email address/addresses) using non-Microsoft default email client (Lotus Notes) as an attachment with an auto-populate subject line (where account number, date and time taken from the fields in document). i.e. - "Incoming call for ABC funds received: <account number> @ <date/time>"..
Any suggestions? Thanks in advance
Nirav Tag: show label dialog box Tag: 53201
Can one save a reference added to project when automating Word
Can one SAVE a reference added to a project when automating Word using a
Word object?
I want to do this from within VB 6, but I find that I cannot do this even
from within Word itself?
For example, using the code below (obvious pieces of code are omitted), one
gets the desired result, i.e., all of the following are executed.
Debug.Print "Found(1): " & ref.Name
Debug.Print "Found(2): " & ref.Name
Debug.Print "Found(3): " & ref.Name
However, if I instead use the Word object, say:
dim appWord as Word.Application
set appWord = New Word.application
and use, e.g.,
Set docNew = appWord.Documents.Add(NewTemplate:=False,
DocumentType:=wdNewBlankDocument, _
Template:=strTemplate)
instead of
Set docNew = Documents.Add(NewTemplate:=False,
DocumentType:=wdNewBlankDocument, _
Template:=strTemplate)
The 3rd test fails and the following is executed:
Debug.Print "Not Found(3): " & strReference, Err.Number,
Err.Description
Is this behavior documented?
Is there a way to SAVE a project after adding a Reference when automating
Word?
-----------------------------------------------
Dim docWord As Word.Document
Dim docNew As Word.Document
Dim ref As VBIDE.Reference
Set docNew = Documents.Add(NewTemplate:=False,
DocumentType:=wdNewBlankDocument, _
Template:=strTemplate)
Set docWord = docNew.AttachedTemplate.OpenAsDocument
With docWord
' add a reference here, then do the following
For Each ref In .VBProject.References
Debug.Print ref.Name
Next ref
If .VBProject.Saved Then
Debug.Print "Project was not modified"
Else
Debug.Print "Project was modified"
End If
On Error Resume Next
Set ref = .VBProject.References(strReference)
If Err.Number = 0 Then
Debug.Print "Found(1): " & ref.Name
Else
Debug.Print "Not Found(1): " & strReference, Err.Number,
Err.Description
End If
.Save
.Close savechanges:=wdSaveChanges
End With
With docNew
For Each ref In .AttachedTemplate.VBProject.References
Debug.Print ref.Name
Next ref
On Error Resume Next
Set ref = .AttachedTemplate.VBProject.References(strReference)
If Err.Number = 0 Then
Debug.Print "Found(2): " & ref.Name
Else
Debug.Print "Not Found(2): " & strReference, Err.Number,
Err.Description
End If
.Close
End With
Set docWord = Documents.Add(NewTemplate:=False,
DocumentType:=wdNewBlankDocument, _
Template:=strTemplate)
With docWord
For Each ref In .AttachedTemplate.VBProject.References
Debug.Print ref.Name
Next ref
On Error Resume Next
Set ref = .AttachedTemplate.VBProject.References(strReference)
If Err.Number = 0 Then
Debug.Print "Found(3): " & ref.Name
Else
Debug.Print "Not Found(3): " & strReference, Err.Number,
Err.Description
End If
.Close
End With
--
http://www.standards.com/; See Howard Kaikow's web site. Tag: show label dialog box Tag: 53186
Adding a counter in a document
I need to create an invoice with a counter for the invoice number. Program will be opened and closed through out the day and the counter needs to keep up with the number of times the invoice is printed. Can any one give me some tips on just how to do that?
--
No Bush in 2004!!!!!! Tag: show label dialog box Tag: 53177
Find and replace with lower case
Is there any (easy) way to do a global search using wildcards and then
replace the found text with its lower case equivalent? E.G.
<index1>MAPLE</index1> with <index1>maple</index1>? It seems obvious but I
can't find it in the program.
Thanks,
Jon. Tag: show label dialog box Tag: 53174
This File is in use by another Application or User (Normal.dot) in Word 2003
I have read many, many posting on this subject but none come close to my
scenario, which is:
1) I have this code snuipped from an Access 2003 application that creates
documents mased on templates and inserts values from an Access table:
'Start of Code Snippet.
... (some code)
Set objWord = New Word.Application
With objWord
' open a new templat instance.
.Documents.Add Template:=(strDocPath)
' save the document in the default dir.
.ActiveDocument.SaveAs FileName:=stNewDocName,
FileFormat:=wdFormatDocument
.Documents(stNewDocName).Activate
End With
... (some code that sets the bookmarks in the document(s) to appropriate
values
With objWord
' close the document and save the change.
.Documents(stNewDocName).Close SaveChanges:=wdSaveChanges
' quit word
.Quit
End With
End of code snippet
Under Windows 2000 and Office XP this worked fine, but under Windows 2003 &
Office 2003 the .Close statement generates the "This file is in use by
another application or user" message citing Normal.Dot. I am stumped. Any
ideas?
Thanks, Brad Marshall Tag: show label dialog box Tag: 53167
Keyboard shortcut question
I suspect there is not a way to do this but I'll ask anyway.
I'm working on a large application in Word that among other things,
inserts SGML tags. I have a list of 432 standard tags that can be
inserted into the document. So far I have avoided having to hard code
the list of tags into the code by having a text file with the list of
tags. That way I can retrieve the names of the tags and pass them as
arguments to the different subroutines that insert the tags. I was
able to do this when applying tags using toolbar buttons (by setting
the parameter of the toolbar button and retrieving it in the sub that
applies the tag) and also in a user form that presents the user with a
listbox with all the tags in it.
However, I've now hit a wall. They need to be able to apply tags using
keyboard shortcuts. There are the issues I've found:
1. I can't assign a macro that takes an argument (even if it's
optional) to a keyboard shortcut.
2. I can't seem to discover which keyboard shortcut fired the
subroutine.
3. There is a CommandParameter argument when adding a keybinding,
however, it doesn't appear to do what I need. (It's used when
assigning a command such as FontSize to a shortcut to specify what
size.)
At this point the only way I can see to do this would be to create a
subroutine for each tag (all 432 of them) that would simply call the
macro that inserts the tag passing the name of the tag to it.
What is particularly annoying is that I've given the users the ability
to create custom tags on the fly for those rare cases where there is
not an appropriate standard tag. They want to be able to assign
shortcut keys to these also but if I can't use a generic macro to
insert the tag by passing the tag name, this isn't going to happen.
Thanks for your time!
KathyK
Grand Rapids, MI
--
Kathy
*****
"Use what talent you possess: the woods would be very silent if no birds sang except those that sang best."
-Henry Van Dyke (1852-1933) American scholar, educator, lyricist Tag: show label dialog box Tag: 53164
create a table within a table in vba?
hi,
in a word doc., i have 3 tables. in vba for word xp, how can i create a table within one of the tables?
thanks,
william.
--
-- Tag: show label dialog box Tag: 53163
create shortcut to active document and place in a folder
This is really a vba question yet I neglected initially to send it to
the vba group.. I've cancelled the original messages, which had some
mistakes, and I'm starting over.
Is there a command that I could run through VBA that would create a
shortcut to the active Word document and place that shortcut in a
particular folder? Let's say the folder is: C:\Documents\Work
The manual equivalent of this, which I already have, is to add to the
Windows/SendTo folder a shortcut to a .vbs file which sends a shortcut
of the document to the folder. But I want to automate this from within
Word.
Here is the code of the .vbs file. A shortcut to this .vbs file is in
my Windows\SendTo folder. :
Dim fso, Package, PkgName, Destination, link, Top, I
Destination = "C:\Documents\Work"
Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Top = WScript.Arguments.Count
For I = 0 To (Top-1)
Package = WScript.Arguments.Item(I)
PkgName=fso.GetBaseName(Package)
Set link = shell.CreateShortcut(Destination&"\"&PkgName&".lnk")
link.TargetPath = (Package)
link.Save
Next
' MsgBox "Shortcuts to the file(s) or folder(s) are being created
at:"&vbCRLF&Destination
Set shell = Nothing
Set fso = Nothing
Also, in addition to placing a shortcut in the folder, would there be a
command I could run through VBA that would delete the shortcut of the
active document from the C:\Documents\Work folder?
I'm basically trying to come up with a more powerful equivalent of
Word's Work
menu.
I'm working with Word 97, on Windows 98.
Thanks,
Larry Tag: show label dialog box Tag: 53160
Do I need to use VBA?
I am hoping to make a template such as the following:-
On [insert date] at [insert time], I was at [insert location] with [insert
friends]. We visited [insert places you visited] and did [insert activites].
Now, what I would like is for when I open the document, for a serious of
questions to pop up in MS Word, for example, "insert date," "insert time,"
"insert location" etc..... and then all these fields fill in automatically.
It's similar to those website you can go to where you get asked a serious of
questions and it then automatically personalises a story for you!
I am using Office 2000.
Thanks all Tag: show label dialog box Tag: 53155
Template with checkbox and textbox - how to code
Hello,
I'm not not a programmer, so thought of pitching my question here.
In this template,there is a series of check boxes and only one would be selected at any given time, and a textbox where additional comments will be added. I have inserted objects (check boxes and a text box) - how to make it functional? In properties or in VBA subroutines?
Thanks - Tag: show label dialog box Tag: 53150
Triggering a macro to run when a template is used to create a new document
I created a new Word template (in Word 2002), and I
would like a macro to run automatically when the user
creates a new document from the template. The macro is
attached to the template, and I named the macro:
Document_New
The macro runs automatically (and does what I want it
to do) when I open the template. But the macro does not
automatically run when I create a new document from the
template.
What do I have to do to get the macro to run
automatically? Tag: show label dialog box Tag: 53148
Duplexing printer?
I hope Jonathan West is reading this, I am trying to use your VBA code you have posted. It runs through all the code with no errors when I step through but when it is finished the duplex code has not changed. I am using a Lexmark T622.
Thanks for any help you can give me. Tag: show label dialog box Tag: 53136
Word's disabled items list
Does anyone know of a way to access Word's disabled items list
programmatically, or failing that, does anyone know where it is actually
stored?
While demoing a batch document conversion tool, I had a failure opening a
Word 2000 document due to a bug in Office 2003 (fixed, there's a patch for
it). Unfortunately all 881 documents in the queue following the one that
caused the crash are now disabled and I'm being prompted to click and enable
each one. I can do that of course, but it would be a little better if I
could give potential users a better workaround than this. :) Tag: show label dialog box Tag: 53135
create table
hi,
in vba for word xp, how can i insert the table to the very, very end of the first page of the doc.? put a frame at the end, and insert the table to it?
thanks,
william.
-- Tag: show label dialog box Tag: 53132
Need .Type codes and constants (e.g. Type 10 is msoLinkedOLEObject
Hi,
I have searched but cannot find the list of Shape and InlineShape type codes.
I would like to find the documentation that describes all codes for Shapes and InlineShapes -- e.g. Type 10 is msoLinkedOLEObject.
Can you help?
Thanks, Regards,
Gary Tag: show label dialog box Tag: 53131
Macro not working in Word 2003
Using the code below in Word 2000 a macro I was using worked just fine.
After upgrading to Word 2003 it no longer works correctly. In fact if I
execute the macro on a table with more than one row in it, the screen just
starts flashing and I have to halt Word with the task manager.
Here's the code:
Dim marker As String
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
With Selection.Find
Do While .Execute(FindText:="", _
Wrap:=wdFindStop, Forward:=True) = True
marker = Selection.Text
Selection.Delete
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
_ PreserveFormatting:=False
Selection.TypeText Text:="INCLUDETEXT " & Chr(34) &
"I:/htltr/jdltr/prod/" & marker & ".doc" & Chr(34) & " B" & marker
Selection.MoveRight wdCharacter, 2
ActiveWindow.View.ShowFieldCodes = Not
ActiveWindow.View.ShowFieldCodes
ActiveWindow.View.ShowFieldCodes = Not
ActiveWindow.View.ShowFieldCodes
Loop
End With
ActiveDocument.Fields.Update
Here's what I see happening when I execute that code:
Example, I have a table with two rows, both of which are highlighted:
2136
2130
The macro selects 2136 and replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/2136 .doc B2136 }then (I think) it selects
2130 but replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/ .doc B }
and then the screen just keeps flashing requiring me to open the task
manager and end Word.
If I have a single row table, such as:
2136
Then the macro selects 2136 and replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/2136 .doc B2136 }
and then ends normally, instead of going into a continuous loop. However,
that results in a filename error because the macro is inserting a " " (blank
space) between the filename and the .doc extention.
Any suggestions or assistance correcting this problem would be greatly
appreciated.
Thanks,
Roger Tag: show label dialog box Tag: 53127
Compile Error
I hope this is the correct place to post this question.
Back in December I apparently acquired a Trojan Horse
that resulted in significant problems requiring removal
and re-installation of Windows XP Home and my various
programs. Since that time, whenever I am in Word I get
the following error message:
MS Visual Basic
Compile error in hidden module: AutoExec.
Can anybody help me get rid of this error message/problem?
Thanks,
Carol Tag: show label dialog box Tag: 53124
WinSelChange major bug
Hello,
I'm using the word application event model, more especially
WindowSelectionChange.
In the particular situation I will describe, Sel.Start, Sel.End and
StoryLength are offseted by 127. The bug is consistent across Word 2K or
Word XP, no matter the SP's are. I haven't checked yet 2K3.
Say the user type 5 characters in a new document. Select some of the
characters.
Do a cut. A WindowSelectionChange is trigerred. When the
WindowSelectionChange is entered Sel.Start and Sel.End are audited thanks to
debug.print or the watch. Nothing wrong at this stage.
Now, instead or doing a cut, type any character, a space for instance. When
the WindowSelectionChange is entered Sel.Start, Sel.End, StoryLength are
wrong. They are offseted by 127.
Is it a known bug?
Is there a workaround?
Thank you
Nicolas Tag: show label dialog box Tag: 53123
Smart Tags
Hi,
Where can I learn more about Smart Tags and their
interaction between Word and Exchange/Active
Directory/other databases?
If I type a name, I can click on the tag and find the
address.
/ Ulf Tag: show label dialog box Tag: 53121
copy image from template to activedocument
Hi,
I want to copy an image from the primaryheader of a template to the
primaryheader of activedocument. I could use clipboard or write to file,
but isn't it possible to copy just from one document to another?
thanks for your help!
greetings
florian Tag: show label dialog box Tag: 53120
Word Automation with VBScript
I am using VBScript for a very simple Word automation task, which consists in opening a HTML file and saving it as a Word document. In order to generate a standalone document, I need to break the links of all InlineShapes, so that they are saved along with the document. From Word, I do this using menu "Edit->Links", selecting all files, and using the "Break Link" button, which is very fast. From VBScript, I tried looping through the InlineShapes and using LinkFormat.BreakLink, which works, but it takes ages when the document has plenty of links. Does anyone know how I can perform the same task as when using "BreakLink" button from the "Edit->Links" dialog box, from VBScript?
Thanks. Tag: show label dialog box Tag: 53114
How to stop looping search at end of document?
I have a macro which is designed to find an occurrence of a string of text,
copy it to a variable, and add some XML tags containing that variable. I
then want it to repeat the process down the document to find the next
occurrence and so on. How can I write a loop that will stop when it reaches
the last occurrence in the document?
The part that I want to loop follows:
Thanks,
Jon.
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<title>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Extend
Selection.Extend Character:="<"
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Title = LCase(Selection)
Selection.Collapse (wdCollapseEnd)
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="<indexterm><index1>"
Selection.InsertBefore Title
Selection.Collapse (wdCollapseEnd)
Selection.TypeText Text:="</index1><index2>"
Selection.InsertBefore Keyword
Selection.Collapse (wdCollapseEnd)
Selection.TypeText Text:="</index2></indexterm><" Tag: show label dialog box Tag: 53109
activating and deactivating a device
Is it possible to activate or deactivate a peripheral device
without using the windows device manager
but using a program ?
I think VBA can do this, but... how ?
--
David C. Tag: show label dialog box Tag: 53101
highlight macro word 2003
Basically I'm trying to create a macro that finds (ctrl-f) certain words
throughout the entire document and highlight them different colors. The
macro records fine but when I run it it does 1 of 3 things. 1st it may not
highlight any words even if they are present in the search criteria. 2nd it
may highlight the entire document and lastly it may find the first word and
highlight only it. I don't currently have any virus's and never had on this
system. Besides I tested this on another system using word 2003 with the
same result and I didn't use the macro I created, I started fresh. Any
idea's or suggestions would be appreciated. This is a daily task of about
20 pages and up to 12 different words so any help would be wonderful.
Thanks Tag: show label dialog box Tag: 53097
finding markups in a word document
Hi,
I'd like use vba to modify an existing document
so that only those pages that contain markups
are saved (i.e. remove all pages that don't contain
markup)
Any help would be much appreciated.
I'm using the word 2003 object model
Thanks Tag: show label dialog box Tag: 53096