Word mail merge doesn't see all contacts in Excel
When I do a mail merge in Word pulling in a list of contacts from Excel, only
the first 104 contacts are found. What's wrong? Tag: Macro Tag: 118105
Multipage/Multitab user form
Hello,
I have a Multipage/Multitab userform that have set the visible=false for the
last page/tab... So usually only 3 tab/pages are visible on this user form...
upon checking of a checkbox on thrid page I would like to make the
hidden/invisible page/tab to visible=True and collect some more data from the
newly visible page/tab and then after that make that page invisible again...
How can I do that?
--
Jeff B Paarsa Tag: Macro Tag: 118102
Bold Text
Hi,
I have the following code:
ActiveDocument.Bookmarks("bkRec2").Range.Text = frmAddl.ComboBox2.Text
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.Range.Text = frmAddl.txtRec2.Text
it works just great. Problem is, I have to BOLD the frmAddl.combobox2.text
and nothing else. I've tried all kinds of ways to to this but can't get it
to bold, or everything bolds.
Can you help?? Thanks Tag: Macro Tag: 118099
Word 2000 - Copy one style from normal
I need to copy one style from the normal.dot (User Profile) to the current
document area. Seems like it would be easy but having some difficulty.
Any help is greatly appreciated.
--
CLG Tag: Macro Tag: 118098
Revisions Marks
In Word 2003, when I loop throught the revisions marks, in some cases, I
get an error message "object is required". What should I do to avoid this?
Any help would be appreciated.
For Each oRev In Application.ActiveDocument.Revisions
If Not (oRev Is Nothing) Then
If oRev.Type = wdRevisionDelete Or oRev.Type =
wdRevisionInsert Or oRev.Type = wdRevisionReplace Then
If strUser = "" And strDate = "" And bIsCheckHighlight
Then
oRev.Range.HighlightColorIndex = m_colorHighlight
ElseIf Not (strUser = "") And bIsCheckHighlight Then
If UCase(oRev.Author) = UCase(strUser) Then
oRev.Range.HighlightColorIndex = m_colorHighlight
ElseIf Not (UCase(oRev.Author) = UCase(strUser)) Then
oRev.Range.HighlightColorIndex = wdNoHighlight
End If
ElseIf Not (strDate = "") And bIsCheckHighlight Then
If DateValue(oRev.Date) = DateValue(CDate(strDate))
Then
oRev.Range.HighlightColorIndex = m_colorHighlight
End If
Else
oRev.Range.HighlightColorIndex = wdNoHighlight
End If
End If
'If MsgBox(Print_Debug(oRev), vbOKCancel) = vbCancel Then
'Exit Sub
'End If
End If
Next oRev
Thanks in advance.
Stephen Tag: Macro Tag: 118095
Revision Object
From Word 2003, when I run the code to loop through all revisons marks, I
get an error "object is required" in some cases. So what should I do to
avoid this error? Any help would be appreciated.
For Each oRev In Application.ActiveDocument.Revisions
If Not (oRev Is Nothing) Then
If oRev.Type = wdRevisionDelete Or oRev.Type =
wdRevisionInsert Or oRev.Type = wdRevisionReplace Then
If strUser = "" And strDate = "" And bIsCheckHighlight
Then
oRev.Range.HighlightColorIndex = m_colorHighlight
ElseIf Not (strUser = "") And bIsCheckHighlight Then
If UCase(oRev.Author) = UCase(strUser) Then
oRev.Range.HighlightColorIndex = m_colorHighlight
ElseIf Not (UCase(oRev.Author) = UCase(strUser)) Then
oRev.Range.HighlightColorIndex = wdNoHighlight
End If
ElseIf Not (strDate = "") And bIsCheckHighlight Then
If DateValue(oRev.Date) = DateValue(CDate(strDate))
Then
oRev.Range.HighlightColorIndex = m_colorHighlight
End If
Else
oRev.Range.HighlightColorIndex = wdNoHighlight
End If
End If
'If MsgBox(Print_Debug(oRev), vbOKCancel) = vbCancel Then
'Exit Sub
'End If
End If
Next oRev
Thanks in advance. Tag: Macro Tag: 118094
Document Preview
Hi All
What I would like to do, is to on a Word UserForm is to get a preview of a
Word Document.
Any ideas.
Regards
D Tag: Macro Tag: 118093
Images, forms, and VBA in MS Word
Hi all.
I currently have a template with a VBA form that allows my users to enter
data and have my report auto-build.
Unfortunately, I will need to be able to add an image to the document (along
with a caption) using the form mentioned above. I have managed to get the
image to be inserted into the document, but there are some issues.
First, the image is inserted at the beginning of the page. Not at the
bookmark. Of course, this is because I haven't associated the image with a
bookmark yet...no clue how to. Go figure.
Second, there is no user confirmation of the filename for the image selected
on the form.
I have a fairly simple solution, but I'm not sure how to put it into the code.
1. User clicks button next to text box.
2. Dialog opens allowing user to select a file from the pc.
3. Document name fills into the text box on the form which is next to said
button.
4. When user clicks 'submit' on the form, the code ties that filename to the
actual file and inserts it into the document AT MY BOOKMARK!!! =)
This process will need to be repeated multiple times, but there is no set
amount of times. As a result, I am putting about 5 bookmarks in for the
images (all on top of each other) and will need to put the line breaks into
the form to force the lines to move down if an image is inputted... (I think
I might be able to handle that part...MIGHT) If no image, the bookmarks just
sit next to the first picture harmlessly. There will always be at least one
image, but how many there will acutally be in the end will vary...
The basic text-inserts of the form are working beautifully, so I don't seem
to need any help there right now. What I need is a simple code sample that
will get me through steps 1 through 4 above. I can manipulate it to
accomodate my filenames and requirements, but I don't know where to begin!!!
Thanks in advance to anyone able or willing to help!
Kim Tag: Macro Tag: 118092
Code to alter envelope address location
I can alter the font and font size, but I can't alter from left and from top.
I've tried to adjust the frame, but I can't find code to do that.
Any help would be greatly appreciated! Tag: Macro Tag: 118091
Is there any way to assign picture for CommanBarPopup
Hello.
I need to set my button on user's toolbar (in left position). By
clicking on my button should opens list of some values. I tried to use
type of button as msoControlPopup, but it hadn't picture as like it
can be for msoControlButton.
Question: is it possible to assign any picture for my button with type
msoControlPopup?
If it impossible then what I can use for my button to open some list?
And how?
Thank you very much. Tag: Macro Tag: 118089
Find Revisions by Date
I found some strange behavior when trying to find revisions with
specific date:
- Open a document, enable revision tracking
- Begin editing the document
- Change computers date to e.g. one month in Future
- Continue editing the same paragraph
Now you have two sections in one paragraph with two different revision
dates.
When holding mouse over each section, word shows the exact date of
change.
In VBA Editor ActiveDocument.Revisions.Count returns only one
revision, with
the date when started editing.
To examine whats happening, save document in xml format and open in
notepad.
In xml, there are two different annotations with exact dates.
So, the problem is, how can someone programmatically access revisions
with
exact date?
Is this a bug or documented behavior? Tag: Macro Tag: 118087
How to change objects to pictures in Word 2002
We are in Word 2002. On a regular basis, we need to save PowerPoint
presentations as Word documents. When we do this, the file size is very
large, because all of the pictures are saved in Word as objects. We need a
macro that will go through the document and select each object and change it
to be a picture. We tried creating a macro that would cut each picture and
then use PasteSpecial and repaste the object in as a picture -- but we can't
seem to get it to work. Any help with this would be greatly appreciated. Tag: Macro Tag: 118075
Fragile find & replace
I've tried some of the find & replace macros mentioned at various times in
the discussion groups and they do seem to be rather unreliable with certain
complicated documents.
This one, which I copied from a link, seemed to one of the most
straightforward and runs on most documents but sometimes ends up in an
endless loop in certain cases with text boxes inside what I think is a frame
(hatched box which you can't seem to resize).
Any idea what can be going wrong or how I can diagnosis the problem?
Sub FasterResetSpacing()
Application.ScreenUpdating = False
Dim spacingStoryRange As Range
'First search the main document using the Selection
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^?"
.Replacement.Text = "^&"
.Forward = True
.Format = True
.Replacement.Font.Spacing = 0
.Replacement.Font.Scaling = 100
.Replacement.Font.Position = 0
.Replacement.Font.Kerning = 0
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
'Now search all other stories using Ranges
For Each spacingStoryRange In ActiveDocument.StoryRanges
If spacingStoryRange.StoryType <> wdMainTextStory Then
With spacingStoryRange.Find
.Text = "^?"
.Replacement.Text = "^&"
.Format = True
.Replacement.Font.Spacing = 0
.Replacement.Font.Scaling = 100
.Replacement.Font.Position = 0
.Replacement.Font.Kerning = 0
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Do While Not (spacingStoryRange.NextStoryRange Is Nothing)
Set spacingStoryRange = spacingStoryRange.NextStoryRange
With spacingStoryRange.Find
.Text = "^?"
.Replacement.Text = "^&"
.Format = True
.Replacement.Font.Spacing = 0
.Replacement.Font.Scaling = 100
.Replacement.Font.Position = 0
.Replacement.Font.Kerning = 0
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Loop
End If
Next spacingStoryRange
End Sub
Any help much appreciated.
David Turner Tag: Macro Tag: 118074
Word VBA question
Hi all,
Just wondering if anyone can help me with the following.
I am doing up headed company paper....... Is it possible for me to set
up a Macro so that as soon as the document is opened from new it will
ask who the Customer is and insert it to a certain place on the
letter?
I'm hoping to do up a full list of questions for a automatic letter
but if I can get a start on this one I should be able to go from
there!!!
P.S. i'm using Word 2007!
Thanks,
Niall. Tag: Macro Tag: 118066
FileSendMail-macro
Hello NG,
I need help. I must develop a MAPI32.DLL to send files from Word with
File/Send Mail. (This command use the dll under
"HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Microsoft Outlook\DllPath" )
How can I see, what a functions are used from this MAPI-DLL, when I send a
file from Word? Can I edit the Word-command macro FileSendMail?
Kind regards,
KS. Tag: Macro Tag: 118063
Sort Loop Problem
I'm trying to create a file of employees with their dependents. I have
created this procedure to sort the people but I'm getting duplicate
dependents in some cases but not all. I'll appreciate any input.
Thanks.
Private Sub ExportMain()
Dim LogFile As Integer
LogFile = FreeFile
Dim LogFileName As String
LogFileName = "C:\EligFile.txt"
Dim DepNotFound As Boolean
Dim rstMain As Recordset
Dim rstDep As Recordset
Dim db As Database
Set db = CurrentDb()
Set rstMain = db.OpenRecordset("tblMainParts")
Set rstDep = db.OpenRecordset("tblDeps2")
Open LogFileName For Append As #LogFile
Do While Not rstMain.EOF
'Main Subscriber
Print #LogFile, Left(rstMain!Field1 & Space(680), 680)
'Move through dependent records until Dep SSN matches with
Main SSN
Do While Left(rstMain!Field1, 9) <> Left(rstDep!Field1, 9)
rstDep.MoveNext
If (rstDep.EOF = True) Then
DepNotFound = True
Exit Do
Else
DepNotFound = False
End If
Loop
'Write Dependent records while Dep SSN matches with Main SSN
If (DepNotFound = False) Then
Do While (Left(rstMain!Field1, 9) = Left(rstDep!Field1,
9))
Print #LogFile, Left(rstDep!Field1 & Space(680), 680)
rstDep.MoveNext
If (rstDep.EOF = True) Then
Exit Do
End If
Loop
End If
rstMain.MoveNext
rstDep.MoveFirst
Loop
Close #LogFile
End Sub Tag: Macro Tag: 118059
Collapsing Ranges and Inserting Tables..... just can't figure it out.
Hi,
I'm trying to insert a couple of tables into Word, and have spent a
couple of days trying to figure this out. Either the tables merge
together, or they are displayed in the wrong order.
I thought that using Range.Collapse wdCollapseEnd would take to the
end of the specified range.
However, whatever I am doing, it is inserting text at the start of the
range.
Any ideas where I am going wrong.
Many Thanks
Rgds
Neil.
Code Below (I stripped out the code that populates the table cells,
because there would be just too much code to look at):
----------------------------------------------------------------------
Set tRange = objDoc.Bookmarks("client_table").Range
tRange.Collapse wdCollapseEnd
With tRange
.Text = clientFirstName(currentClient)
.Font.Bold = True
End With
With tRange
.Collapse wdCollapseEnd
.Text = vbCr & vbCr
.Collapse wdCollapseEnd
End With
Set ClientTable = objDoc.Tables.Add(Range:=tRange, _
NumRows:=5, NumColumns:=2)
//////////////////////////////////////////
/// Insert Table Cells - works OK
//////////////////////////////////////////
ClientTable.AutoFormat Format:=wdTableFormatContemporary
If partnerFirstName(currentClient) <> "" Then
Set tRange = objDoc.Bookmarks("client_table").Range
With tRange
.Text = partnerFirstName(currentClient)
.Font.Bold = True
End With
With tRange
.Collapse wdCollapseEnd
.Text = vbCr & vbCr
.Collapse wdCollapseEnd
End With
Set PartnerTable = objDoc.Tables.Add(Range:=tRange, _
NumRows:=4, NumColumns:=2)
//////////////////////////////////////////
/// Insert Table Cells - works OK
//////////////////////////////////////////
PartnerTable.AutoFormat Format:=wdTableFormatContemporary
With tRange
.Collapse wdCollapseEnd
.Text = vbCr & vbCr
.Collapse wdCollapseEnd
End With
End If Tag: Macro Tag: 118034
Copying consecutive pages of a .DOC into another documnt's table cells
Hi all,
I'd like to create a macro to copy consecutive pages in a word document
into cells of a table in a separate .doc file. (Each page into separate
cell).
The problem I face is how to "put" a page in the source document into a
range object to subsequently get its contents and "formatting" and
deliver them into the target cell.
Additional question: What if the source page contains a picture or a
text box.
TIA,
Primoz Bradac Tag: Macro Tag: 118033
Handle docx type in VB6.0
hi,
We have been using word automation to generate word documents based on
bookmarks etc from VB6.0 application. Now are researching if we can handle
opem office xml (ie. docx) from vb6, save and retrieve docx format files.,
i'm unable to find any help in terms with handling the open office xml
document in VB6.
Please can you help me with it? Tag: Macro Tag: 118032
How to apply the property "InitialView = msoFileDialogViewList"?
Hello.
There is the code which opens dialog box (below).
Why I can't apply the property "InitialView = msoFileDialogViewList"
for dialog box? Let that primary the dialog had the initial
presentation as "msoFileDialogViewProperties". But after start this
macro the initial presentation don't change. Why?
Sub openDlg()
Dim fd As FileDialog
Dim regPath As String
Dim myPath As String
Dim keyValue As String
Set fd = Application.FileDialog(msoFileDialogOpen)
regPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common
\General"
keyValue = System.PrivateProfileString("", regPath, "RecentFiles")
myPath = Environ("APPDATA") & "\Microsoft\Office\" & keyValue & "\"
With fd
.InitialFileName = myPath
.AllowMultiSelect = False
.Filters.Add "Documents Word:", "*.doc; *.rtf; *.dot; *.docx"
.FilterIndex = 9
.Title = keyValue
.InitialView = msoFileDialogViewList 'here is problem ???
If .Show = -1 Then
.Execute
End If
End With
Set fd = Nothing
End Sub Tag: Macro Tag: 118029
Printing Select Pages in sequence in a file
Hi,
Pls help to print select pages..the issue is..i used to merge a word
document of 7 pages ...with the excel data...which results to hav a file of
654 pages...i have saved it...after some months .i want to print page 2 & 3
..and page 9 & 10..16 & 17..i.e leaving 5 pages which is not required better
it will like
Page 1- not req
Page 2-print
Page 3- print
Page 4 - not print
Page 5 - not print
Page 6 - not print
Page 7 - not print
Page 8 - not print
Page 9 - print
Page 10- print
Page 11- not print
Page 12 - not print
Page 13 - not print
Page 14 - not print
like wise...till the end of the document..is this will happen in word in
one go ..i have to do it manually..i am fed up;
Thanks,
Safi Tag: Macro Tag: 118025
styleref returns nothing
Hi,
I was trying to add in a styleref to the word document (word 03) as follows
Appendix {STYLEREF \s "Heading 4"} - Testing Only
but it shows Appendix (blank) - Testing Only, instead of Appendix A
That styleref works in the footer of the document. Does it only work for the
footer or header?
Thank you in advance Tag: Macro Tag: 118019
MS Word Templates
Iâ??m a physician (radiologist) and also involved with a company in the medical
information systems arena, DR Systems. Inc, based on San Diego. Iâ??m not a
software engineer and something less than a beginner when it comes to VBA. I
wonder if you can help me with the following problem or direct me to a
resource that can.
Iâ??ve been creating templates for radiologists who read MRI, CTâ??s and other
imaging exams, and have been experimenting with form automation. In the
world of health care information systems, we have some limitations. Often
reports must be handed to other information systems using only HL-7 text
strings. So diagrams, buttons, tables, etc are usually not acceptible.
Also, locking forms can be tricky, since physicians usually want to be able
to both use an automated form, but also change or delete just about anything.
Finally, the reporting doctor doesnâ??t really want it obvious to the reader
that he used a form.
Iâ??ve learned to still automate report forms using macrobutton fields, hidden
text, toolbar button-activated macros.
With this background, hereâ??s my issue. Iâ??d like to be able to create the
equivalent of a drop-down menu or listbox such that when you select an item,
the selected item appears as text, meaning that you donâ??t continue to see
evidence of the dropdown. In some cases, Iâ??d like to create the drop down as
part of a macro.
For example, Iâ??d like to show text like: â??The left ventricle is normal.â??
If the doctor clicks this text, it should change to:
â??The <<?>> segment of the left ventricular myocardium shows <<?>>.â??
Where the <<?>> includes a list of available choices. Iâ??m getting close,
but havenâ??t figured out how to add the drop down choices without running into
issues related to form locking. For example, I canâ??t seem to lock just the
drop down. If I had continuous section breaks befor and after the drop-down,
MSWord creates a new line. Also, Iâ??m struggling to create a macro that
itself writes and drop down menu (again, the issue isnâ??t so much inserting
the menu, but dealing with the locking/unlocking). Iâ??ve tried dealing with
the control toolbox as an alternative, but not successfully.
Also, I use hanging indents in my templates, but run into an issue when the
text is sent to other information systems. A hanging indent doesnâ??t result
in any sort of HL-7 message, so the formatting is incorrect when displayed on
other systems. Iâ??d love to figure out a way to add a VB instruction in my
templates that automatically adds a tab whenever there is a soft line break.
Can you help or point me to a resource that can? Iâ??m using MSWord2003, but
would jump to 2007 if itâ??s easier.
--
MAR Tag: Macro Tag: 118018
What does Val return?
The VBA help says the Val function "[r]eturns the numbers contained in a
string as a numeric value of appropriate type." Does this mean that the data
type of the returned value will automatically converted to the data type of
the variable that's calling the function?
For example, in the following contruction
Dim myValue as Long
Dim myString as String
myString = "123 Main Street"
myValue = Val(myString)
will Val return "123" but will it be returned as a Long or do I need to use
CLng to convert it? I know I can just be sloppy and let VBA force the
conversion, but I would prefer to be precise.
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup. Tag: Macro Tag: 118015
How to Load Form using Variable for Name
I have a project I'm working on that will have lots and lots (20-30 or
more) UserForms. As such, I don't want to pre-load them. Instead, I
want to load them as needed. To do so, I've created a combo box on
each form that lets the user choose what form to go to. The User
picks one from the list then clicks on "OK" button. I then want to
load that form and show it. To make it one bit harder my forms are
all named "frm" + Form name.
For example the forms are named, frmMyForm, frmYourForm, frmHisForm
and the combo box shows "MyForm", "YourForm", "HisForm"
The code I have so far for the OK click routine is:
Private Sub cmdChoose_Area_Click()
vChosen = Me.cmbChoose_Area.Value
vName = "frm" + vChosen
Call FormGoTo(Me.Name, vName)
End Sub
In FormGoTo I have the receiving parameters (vFormFrom, vFormTo)
No matter what I do I can't Load "vFormTo".
I've tried
FormGoTo (vFormFrom, vFormTo as UserForm)
but then I get an error from the calling procedure.
I've tried:
Load vFormTo
Load UserForms(vFormTo)
etc, but with no luck.
Is there any way to do this? Tag: Macro Tag: 118013
email form based on drop down value
I have a form in word with a drop down field. I have a submit button
at
the bottom of the form and I want the form to email as an attachment
using code to determine the email address. The code in the "submit"
button should reference the drop down field to determine the
recipient.
For example:
If the dropdown = "service", then email joe@abccompany.com
If the dropdown = "sales", then email mary@abccompany.com
If the dropdown = "billing", then email john@abccompany.com
Can this be done? I have other forms that mail to a specified address
as an attachemnt, but do not know how to have a field refernced like
this. Please help.....
Thanks-
Scott Tag: Macro Tag: 118006
Out of Stack Space????
I have this code below which gets me into the Header rather than going
through the toolbar but the problem is once I get into the header, the header
toolbar Close button is deactivated, I can't get out of the header area and
the document locks up. This then generates an Out of Stack Space message
with this: "ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader" line highlighted in yellow. Any one out there know
what's going on with this and how to solve this. Thanks in advance for your
help.
Sub ViewHeader()
'
' ViewHeader Macro
' Macro recorded 9/16/2008 by dwallace
'
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
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End Sub Tag: Macro Tag: 118004
'PrivateProgramString' of object 'System' failed
The following autorun code worked in Word 2003/Windows XP:
Sub AutoNew()
InvoiceNo = System.PrivateProfileString("C:\Settings-Hannani.txt",
"MacroSettings", "InvoiceNo")
If InvoiceNo = "" Then
InvoiceNo = "1"
Else
InvoiceNo = InvoiceNo + 1
End If
System.PrivateProfileString("C:\Settings-Hannani.txt", "MacroSettings",
"InvoiceNo") = InvoiceNo
ActiveDocument.Bookmarks("InvoiceNo").Range.InsertBefore
Format(InvoiceNo, "00#")
ActiveDocument.SaveAs FileName:="C:\Hannani\Word Files\Invoices\" +
"Hannani Inv 2008-" & Format(InvoiceNo, "00#")
End Sub
I copied everything over to a new computer running Windows Vista and Word
2007 and get the following error:
"Method 'PrivateProfileString' of object 'System' failed"
This is what appears in the referenced Settings-Hannani.txt file:
[MacroSettings]
InvoiceNo=16
It is used to increment an invoice number each time the template is used to
create a new document.
Can you tell why this does not work in Word 2007?
Thanks...
--
singeredel (Julie) Tag: Macro Tag: 118001
Acronym macro - find and print in second file
Hi,
Back in '02 Mark Tangard suggested this snippet to find macros.
With Selection.Find
.Text = "<[A-Z]{3,}>"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = True
.MatchWildcards = True
.Execute
End With
Has anyone (or would anyone like to) used this to create a fuller
macro that reads through file 1, finds acronyms, and writes them and
the page number to file 2? Alternatively, has anyone written a macro
that finds the first use of an acronym and somehow checks that it is
indeed defined (and only defined once!) with that first use?
Cheers, Bruce Tag: Macro Tag: 117998
Why using AutoExit don't delete CommandBarControl from menu?
Hello.
There is one template which has 3 macro. First macro is called
"AutoExec". It create one menu item into menu FILE. The click on this
item launches other macro (3-st macro). Second macro is called
"AutoExit" It delete new menu item from menu FILE.
I placed my template to the folder "StartUp" for Word.
When I start Word into menu File is creates my item. Next I close Word
and delete (manually) my template from folder "StartUp". Again start
Word and see that new menu item wasn't deleted - it there.
Why? I know that auto macro "AutoExit" is run when closing Word or
template. But why then my macro don't run?
Thank you. Tag: Macro Tag: 117997
Sending Picture to behind text using Word Automation With C#
Hi all
I have a word document and I am inserting a picture at a bookmark.
BookMark1.Range.InlineShapes.AddPicture(PictureLocation.Text, ref
readOnly, ref isVisible, ref missing);
What I need to do is to set the picture layout as Behind Text. I know it has
to be a shape to do this so I use the ConvertToShape method but I don't seem
to be able to find a method to set the layout.
Can anyone help please.
Thank You Tag: Macro Tag: 117993
Word page formatting with protection on
I am trying to protect field references that are embedded in the body of a
paragraph. I have been able to do so using protection and exceptions. Once
that is in place page setup is no longer editable. Can someone offer a
solution? Tag: Macro Tag: 117990
Need to find commands behind a ToolBarPopup control
I've inherited a couple of Word templates which have custom toolbars, one of
which has a button, "Report AutoText", which opens a popup menu. One of the
submenu options is "Insert FramedFigure", which appears to do some formatting
and then inserts a small logo image. I can't find any code anywhere in the
macros that does this, and can't find any kind of a link to the image so it
can be changed. How do you identify the commands that run behind one of
these ToolBarPopup controls? Tag: Macro Tag: 117984
Delete page (that includes a header & footer)
I'm trying to delete the last page of a 4 page document. All pages have the
same header and footer.
I've tried macropod's code from 15/8/08 (slightly amended as I'm using late
binding):
objDoc.Application.Selection.Goto 1, -1 ' wdGoToPage, wdGoToLast
objDoc.Bookmarks("\Page").Range.Delete
This clears all the text (except in the header & footer) from the page, but
doesn't actually delete the page! I'm assuming this is because of the header
and footer. How can I actually delete the page? Tag: Macro Tag: 117976
Selecting a particular Frame
Hi
I have had help of here recently to help me batch change 2 frames in a
document.
I need to be able to ensure which frame I am changing. One of the frames
has a bookmark in it but the otherone doesn't I need to be able to change
both frames but there doesn't seem to be any standard as to which is frame 1
and which is frame 2.
Can I set this knowing that one frame has a book mark in it?
Hope this makes sense
Jay Tag: Macro Tag: 117973
How to select Secure printing for a document
Is there a way to activate Secure printing with VBA? I found something about
duplex printing with Word Automation in
http://support.microsoft.com/?kbid=230743. Tag: Macro Tag: 117971
Reg. MS Word Add-in
Hi,
I need to get the print details(number of pages, page range) in my add-
in, when printing is completed.
Is there any callback that can be handled in add-ins to get these
details?
Thanks,
VSP Tag: Macro Tag: 117970
extract characters from inside brackets in string
I've got a combo box containing multiple values, ending in (xxx) where xxx is
any number of characters. I want to write the combo box value to a string but
strip out everything outside the brackets (so I just get the xxx characters).
I looked at using a regex, but it seems a little complicated to get them
working in VBA.
Would anyone be able to rattle off a function that will do that for me? I'd
spend ages working it out but I'll bet someone out there can write that stuff
with their eyes shut :)
cheers
-E Tag: Macro Tag: 117965
Accessing a Word document source
Greetings!
We have a bunch of Word documents that were created long time ago.
One of the software that we use to translate complains about some
track changes were left without accepting or rejecting. I have a
script that supposely accepts all changes to the Word doc, but it does
not work on some of these older documents. I know how to fix this
problem by hand, but I would like to do this programmatically. The
way to fix it by hand is,
1. Open the word document
2. Go to Tools > Macro > Microsoft Script Editor
3. Use Edit > Find and Replace > Find to search for the string mso-
prop-change; you should find something like:
<p class=MsoNormal style='mso-prop-change:"John Johnson"
20071130T1052'"...
4. Remove the part style='mso-prop-change:"John Johnson"
20071130T1052'"
5. Repeat this until you do not find the string mso-prop-change
anymore
6. Save the document and close the Microsoft Script Editor
I am able to open the Script Editor by doing,
var w = WScript;
var word = w.CreateObject("Word.Application");
var doc = word.Documents.Open(file);
//msoHTMLProjectOpenSourceView 1
//msoHTMLProjectOpenTextView 2
var htmldoc = word.ActiveDocument.HTMLProject.Open(2); // This
opens the Microsoft Script Editor
But, the problem is that I would like to do this behind the scenes and
not have the Script Editor come up. I would also like to do a search
and replace on that specific document. I have searched on the
Microsoft site for a solution, but none was found.
I know how to do the search and replace, all I need is to be able to
access the xml side of the Word document.
Any ideas?
thanks,
jic Tag: Macro Tag: 117959
Populate List Box with Word doc names in a folder
I'm creating a user form with two list boxes. The list box on the left
(lstDivisions)has check boxes for Divisions (i.e., 01, 02, 03 etc.). Upon
selecting the desired division, I'd like the right list box (lstAvailDocs) to
display all the names of Word documents that exist in the corresponding
folder number located at G:\Master Specifications. For example, if the user
chooses division 02 on the left, then the right list box should display all
Word documents in G:\Master Specifications\02. The desired 02 folder may
contain other non-Word files, but I only want Word documents to display in
the second list box.
I made a start with the code below, but I need help with the details. Thanks!
-- Steve C
Private Sub lstbxDivisions_Change()
'Runs when a check box in Divisions list box is selected
For x = 0 To lstbxDivisions.ListCount - 1
If lstbxDivisions.Selected(x) = True Then
LastSelected = lstbxDivisions.List(x) 'Check box has been selected
'Following populates the AvailDocs list box with choices made in
lstbxDivisions
With lstbxAvailDocs
Ifile = FreeFile
Open "G:\Master Specifications\" & LastSelected For Input As #Ifile
While Not EOF(Ifile)
Line Input #Ifile, SpecName
.AddItem SpecName
Wend
Close #Ifile
End With
Next x
End Sub Tag: Macro Tag: 117956
How to open recent file momentary?
Hello.
There is the code macro for open dialog "Recent Files" (below).
However when click "Open" on the some selected file then open new
dialog with this file. I'm obliged twice click that open some file.
Qustion: how to open some selected file from dialog "Recent Files" is
for single click? thank you very much.
My code:
Sub openDlgMRU()
im myPath As String
Dim bKey As String
bKey = System.PrivateProfileString("", "HKEY_CURRENT_USER\Software
\Microsoft\Office\11.0\Common\General", "RecentFiles")
myPath = Environ$("appdata") & "\Microsoft\Office\" & bKey & "\"
With Dialogs(wdDialogFileOpen)
.Name = myPath
If .Display = -1 Then
.Show
End If
End With
End Sub Tag: Macro Tag: 117948
Adding InlineShape makes Word freeze
Hi,
I'm adding a picture like shown below.. into Word 2007
Just before adding I get some data from another word file..
When I break the code here and step trough the code with F8 it runs
perfectly , but when it runs without a break Word just freeze
Do anybody know why?
Thanks alot,
Flemming
Dim rBookmark As Range
Dim oIS As InlineShape
Set rBookmark = oDoc.Bookmarks(sBookmarkName).Range
Set oIS = rBookmark.InlineShapes.AddPicture(FileName:=sFullFileName,
LinkToFile:=False, SaveWithDocument:=True)
If Not oBorderLineStyle = wdLineStyleNone Then
With oIS
With .Borders(wdBorderTop)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderBottom)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderLeft)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderRight)
.LineStyle = oBorderLineStyle
.LineWidth = wdLineWidth150pt
End With
End With
End If
End If Tag: Macro Tag: 117947
Why field shading persists
Is there a way to have a Word 2007 .docx file not reveal field shading? The
files in questions start out as .docm and are later saved as .docx.
I know you can unlink field codes by selecting all and doing a Ctrl + shift
+ F9 but since it appears the VB code is gone in a .docx, I do not understand
why the field shading persists?
I am trying to give coworkers simple instruction on how to prepare a Word
2007 file before sending to a customer. The field shading gives a very
undesirable boilerplate appearance should the recipient have the field
shading option turned on to always. The field shading persists with the .dox
file, a surprise to me.
Has anyone ever run into this and have an easy solution? Tag: Macro Tag: 117944
Disappearing code
I had a Word template with some form fields.
I used the Visual Basic editor to write some macro code for when the
document closes.
I did a Save As and saved the template as a new name.
When I open that template, I can't find the macro code, as if it just
disappeared?
Am I doing something wrong? Tag: Macro Tag: 117940
Using VBA how do set the position of a table I'm creating.
I'm using the following to create a table.
Set tblNew = docActive.Tables.Add( _
Range:=docActive.Range(Start:=0, End:=0), NumRows:=2, _
NumColumns:=3)
How do I change the location of the table? If I put values in Start and End
I get an app error, value out of range. I used 5 for both Start and End. Tag: Macro Tag: 117938
Import Access Query into Form Fieldson in a Template
I have a User Form with Form Fields that have bookmarks that identify each
field. I also have an Access Database that has corresponding fields.
Corresponding fields:
ProjectTitle
ProjectCatagory
ProjectLeader
TeamMember1
TeamMember2
Is it possible using VBA to import from the Access Query into the opened
Template, the corresponding fields? Some how the user would have to select
the Record wanted, but I think the fields could already be identified in the
code.
Also, would the Template have to be unprotected?
--
Your guidance is greatly appreciated! Tag: Macro Tag: 117937
Mailmerge, open Data Source through macro
Hi
We have two templates, one containing a list of clients and one with a
standard letter. The one with the list of clients is the source for the
other, so we can easily create a letter to a long list of clients.
I would like to create a AutoNew macro in the template with the standard
letter that opens the "Select Data Source" for mailmerge when opened, but
can't figure out how?
/Lasse Tag: Macro Tag: 117934
How to use the function for find some text?
Hello.
Mr. Allen Wyatt publish code of one function which provide replace one
text to other (http://wordtips.vitalnews.com/Pages/
T000811_Replacing_Text_in_a_Macro.html). However I can't call it into
macro. How to correct take advantage of the opportunity this function?
That is this function and my macro:
Function RepText(sIn As String, sFind As String, sRep As String) As
String
Dim x As Integer
x = InStr(sIn, sFind)
While x > 0
sIn = Left(sIn, x - 1) & sRep & Mid(sIn, x + Len(sFind))
x = InStr(sIn, sFind)
Wend
RepText = sIn
End Function
Sub findWord()
sIn = Selection.Text
sFind = "the"
sRep = "of"
End Sub
Thank you for your tips. Tag: Macro Tag: 117930
How can i insert a command button that will ask the user which macro they
want to run from a list of available macros?