Over 1 million tech questions and answers.

Solved: Word 2010 Macro Insert Text from File

Q: Solved: Word 2010 Macro Insert Text from File

I'm trying to create a macro in Word 2010 that will allow me to insert text from file but pauses when it takes me to the specific folder so that I can select which file to insert. I have a folder containing over 50 files from which I want to choose.

I created this macro once from directions I found on line but my macros were recently lost and I'm having to start all over. I can't for the life of me remember the code for the macro and I can't even remember what question I asked to get to the code previously!

RELEVANCY SCORE 200
Preferred Solution: Solved: Word 2010 Macro Insert Text from File

I recommend downloading and running Reimage. It's a computer repair tool that has been proven to identify and fix many Windows problems with a high level of success.

I've used it in the past to identify and fix everything from blue screens (BSOD's), ActiveX errors, corrupt files and processes, dll/exe/sys errors, recover lost memory, Windows update problems, defragging, malware removal etc.

You can download it direct from this link http://downloadreimage.com/download.php. (This link will automatically start a download of Reimage that you can save to your computer.)

A: Solved: Word 2010 Macro Insert Text from File

Read other 12 answers
RELEVANCY SCORE 117.2

I am trying to create an AutoOpen VBA Macro in Word 2010 files for automatically inserting the same dates into 2 different text boxes when I first open the file. Ideally, I would want 1 file to do this always for Yesterday's date (whatever that may be) and another file to do this for Friday's date (whatever that may be).

Reason for this is because our mail room gets mail the day before I get it on my desk and I need to date stamp it using a Word 2010 template where I have 2 text boxes (please see attached file--oh, doesn't seem like I can attach the file???) for Tuesday through Friday. Right now, I am using the Macros I have created (1 for Yesterday's Date and another Macro for Friday's Date which is Date() -3).

I want to use that Macro logic to put that into the Text boxes I have when it first opens? Please help me with this anyone......

It doesn't seem like I can attach the file so here is the VBA code:

Sub AutoOpen()
'
' AutoOpen Macro that places the cursor at the last position of edit (not default of top left) (will work with Protected View)
If Application.ActiveProtectedViewWindow Is Nothing Then
Application.GoBack
End If

' InsertTextBox1 Macro
Dim Shp As Shape
Set Shp = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationVertical, _
Left:=22, Top:=252, Width:=25, Height:=170)
Shp.TextFrame.TextRange.Text = "NMM RECEIVED: "
Set Shp = Nothing
Selection.InsertAfter Format(Now() - 1, "dddd, ... Read more

Read other answers
RELEVANCY SCORE 117.2

I am trying to create an AutoOpen VBA Macro in Word 2010 files for automatically inserting the same dates into 2 different text boxes when I first open the file. Ideally, I would want 1 file to do this always for Yesterday's date (whatever that may be) and another file to do this for Friday's date (whatever that may be).

Reason for this is because our mail room gets mail the day before I get it on my desk and I need to date stamp it using a Word 2010 template where I have 2 text boxes (please see attached file--oh, doesn't seem like I can attach the file???) for Tuesday through Friday. Right now, I am using the Macros I have created (1 for Yesterday's Date and another Macro for Friday's Date which is Date() -3).

I want to use that Macro logic to put that into the Text boxes I have when it first opens? Please help me with this anyone......

It doesn't seem like I can attach the file so here is the VBA code:

Sub AutoOpen()
'
' AutoOpen Macro that places the cursor at the last position of edit (not default of top left) (will work with Protected View)
If Application.ActiveProtectedViewWindow Is Nothing Then
Application.GoBack
End If

' InsertTextBox1 Macro
Dim Shp As Shape
Set Shp = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationVertical, _
Left:=22, Top:=252, Width:=25, Height:=170)
Shp.TextFrame.TextRange.Text = "NMM RECEIVED: "
Set Shp = Nothing
Selection.InsertAfter Format(Now() - 1, "dddd, ... Read more

A:Word 2010 VBA AutoOpen Macro to Insert Dates Into Text Boxes

Read other 16 answers
RELEVANCY SCORE 95.6

I cannot find up to date, step by step instructions on creating a macro in Word 2010 on Windows 7.
While in Word, View, I see Create Macros.
And I can name it and paste in this info below.

Sub PrintCurrentPage()
Application.PrintOut Range:=wdPrintCurrentPage
End Sub

But how do I assign a keyboard short cut to it? Is there a youtube video that is up to date on this?
Thanks.

A:How to insert a Macro into Word 2010 in Windows 7 & Assign Shortcut

Hi and welcome to Seven Forums,

The best way to do this would be to record a macro and in the dialog box that comes up, create a keyboard shortcut. Then record something, it can be anything. Then open the macro dialog box with all the macros listed, click your newly created macro and click edit. Then delete the code and replace it with your own. Save and test it.

Hope this helps
Stephen

Read other 9 answers
RELEVANCY SCORE 90.4

Hi
So basically I'm very new to macro and have no idea!

My boss has asked me to find a way to make a word document do the following:

Have a check box to click - when clicked this will copy in a bunch of text from another document saved on our server/(insert text from file). Then when unchecked it will go away.

I have tried everything and it just wont work.
Does anyone have any ideas? Is this even possible?

Any help is appreciated!
 

A:Help - Macro to insert/copy another file into a word doc?

Would be much easier in Excel if that is any use? Word VBA is very challenging I find.
 

Read other 2 answers
RELEVANCY SCORE 86.8

Can someone give me a code sample to insert a small txt file into a completed document. I have a Word 2000 template with a custom userbox and in one of the fields on the userbox, I want to give the option to insert a very small notepad text file into the document, if that option is selected, and I don't know what the code should be. Thanks.
 

A:Insert a text file into a Word 2000 document

Can someone give me a code sample to insert a small txt file into a completed document. I have a Word 2000 template with a custom userbox and in one of the fields on the userbox, I want to give the option to insert a very small notepad text file into the document, if that option is selected, and I don't know what the code should be. Thanks.
 

Read other 1 answers
RELEVANCY SCORE 84.4

I recorded a Word 2003 macro to do the following:

1) Locate the next graphic (which is formatted "inline") in a document
2) Navigate to some text adjacent to the graphic
3) Cut the text to the clipboard
4) Insert a caption pasting the clipboard contents to become the text of the caption

The macro runs correctly except that it fails to record the pasting of text in step 4. The first time it runs the clipboard contains the correct text (which for the example used in this post is $$Image A$$) and that is pasted into the insert caption dialog box correctly. But when the macro runs the second time, with the cursor between the first and second graphics, although it places the second text block in the clipboard, the text from the first caption is incorrectly used in the second caption. In subsequent runs of the macro all captions are set with the incorrect $$Image A$$ text. The clipboard has the correct text (verified by pasting elsewhere) which fails to get pasted into the caption dialog box.

Although I am a VBA novice, I can see from the last line of the macro in the VBA Editor that the Title field has recorded the first caption rather than a paste command. Here's that last line:

Selection.InsertCaption Label:="Figure", TitleAutoText:="", Title:= _
". $$Image A$$", Position:=wdCaptionPositionBelow, ExcludeLabel:=0

Apparently the Macro Recorder won't allow me to record a paste command via Cntr-V. Can I modify this last line in... Read more

A:Solved: Insert Caption with Word 2003 Macro

Read other 8 answers
RELEVANCY SCORE 82

I have created a document in MS Word 2010 that has a textbox with a background color. When I print the document to my printer (have tried multiple printers) or print to PDF, the textbox prints but the text itself does not print. (see attached image)

Upon further investigation of the PDF, I found that the text is actually layered below the textbox. For some reason, Word is printing the textbox on top of the text itself.

When I take the textbox, copy it to a new document, and try to print, it prints correctly.

I have also checked my printing preferences and I believe all the settings are correct.

Does anybody know how to fix this?
 

A:Solved: Word 2010 not printing text inside text box

Read other 13 answers
RELEVANCY SCORE 81.6

edit:
Mods - please move this into 'Software Development'. I need a script to accomplish this task.
I have a Word document, table and column formatting, which is an index of movies, and I want to insert a link in each title, directly to the movie file.

This can be done?

Then, the REAL question - I have 6,000 items, about 50 per 'cell', for each 50 movie files in each folder. I need a script to do this - at least for each 'target' folder of items, at one time...

Feedback?
 

Read other answers
RELEVANCY SCORE 80

Ok here goes, I know how to create macros and even write them. But, Specificly, is there a way to create a macro that will delete all the text in a document (in MS Word)but not the cells or text in certain cells? I know this isn't an easy one. Many thanks to those who try. T out
 

A:Solved: Word: Need Macro to Clear Most Text, but Not All.

Read other 7 answers
RELEVANCY SCORE 80

I'm trying to create 4 macros that open different folders. I can only get one to work.
for example I created a macro called WordDir below is the content

Sub WordDir()
'
' WordDir Macro
'
'
Sub OpenFolder()
With Application.Dialogs(wdDialogFileOpen)
.Name = "F:\Word"
.Show
End With
End Sub

works great and opens f:\word.

at this point I noticed it created an openfile macro

If I create another for example

Sub WordDirclient()
'
' WordDirclient Macro
'
'
Sub OpenFolder()
With Application.Dialogs(wdDialogFileOpen)
.Name = "F:\Word\client"
.Show
End With
End Sub

Does not work, actually it shows the first directory. I believe it has something to do with the openfile macro created by the firt macro

Any ideas???
 

A:Solved: MS WORD 2010 macro

Issue the command below to change the "FileOpen" directory prior to showing your dialogue.
Code:
Application.ChangeFileOpenDirectory "F:\Word\client"

Rollin
 

Read other 2 answers
RELEVANCY SCORE 79.2

Hello All....
i'm newbie in programming..i have a question how to develop a program / macro vba in excel.
so, i have a data in sheet1, e.g :

Information Engineering
Industrial Engineering

and then, in sheet2 will be automatically created a text in column A

Informatics Engineering Smt 1
Informatics Engineering Smt 2
Informatics Engineering Smt 3
Informatics Engineering Smt 4
Informatics Engineering Smt 5
Informatics Engineering Smt 6
Industrial Engineering Smt 1
Industrial Engineering Smt 2
Industrial Engineering Smt 3
Industrial Engineering Smt 4
Industrial Engineering Smt 5
Industrial Engineering Smt 6

Also in Column B the same data
Informatics Engineering Smt 1
Informatics Engineering Smt 2
Informatics Engineering Smt 3
Informatics Engineering Smt 4
Informatics Engineering Smt 5
Informatics Engineering Smt 6
Industrial Engineering Smt 1
Industrial Engineering Smt 2
Industrial Engineering Smt 3
Industrial Engineering Smt 4
Industrial Engineering Smt 5
Industrial Engineering Smt 6

and ofcourse in i write in sheet1 another data, the sheet2 will automatically ajjust the data same with the data just inserted into sheet1

anyone can help ?
many thanks
 

Read other answers
RELEVANCY SCORE 79.2

Hi,
I'm using Microsoft Word 2010
Instead of typing in "today's date" every time.....
How do I modify the date macro I made for Excel so it will work in Word.
And where do i put it ?

Then I can have an Icon on the Ribbon !!
HTML:
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.NumberFormat = "mmmm/dd/yyyy"
Selection.Value = Selection.Value
mike
 

A:Solved: Macro for date in Word 2010

Read other 6 answers
RELEVANCY SCORE 78.8

Hi,

I am a new poster, thanks in advance for your help.

I use Windows XP and have a bunch of file names in my store inventory that I would like to insert some text into. ie;

vapor.jpg I would like to rename to Airush_09_vapor.jpg &
flow.jpg I would like to rename to Airush_09_flow.jpg

How do I insert the "Airush_09_" into a group of filenames at one time.

Thanks again
 

A:Solved: insert text into a file name

Howdy Windguy99...

If you are wanting to do a batch rename of .jpg files irfanview can do that for you (it's free )

http://www.irfanview.com/main_download_engl.htm
 

Read other 2 answers
RELEVANCY SCORE 78.4

I am trying to write a Macro thath will generate a list of all possible combinations of letters. Was thinking about using ASCII but not sure where to start and can't find a thread or existing snippit that I can understand well enough to modify.

I want a list of strings five characters long that accounts for all possible combinations of 26 letters.

Can anyone help?
 

A:Solved: Word 2010 Macro - Iterative Generator

Read other 6 answers
RELEVANCY SCORE 77.2

Using Outlook 2010 & suddenly I am unable to attach or insert a file or graphic. The insert file box opens but title is followed by (Outlook not responding). I ran repair but that didn't fix. I restarted Outlook and I restarted my computer. Still not working. Thank you for your help.
Tech Support Guy System Info Utility version 1.0.0.2
OS Version: Microsoft Windows 8.1, 64 bit
Processor: Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz, Intel64 Family 6 Model 60 Stepping 3
Processor Count: 4
RAM: 8108 Mb
Graphics Card: Intel(R) HD Graphics 4600, -2016 Mb
Hard Drives: C: Total - 941631 MB, Free - 826579 MB; H: Total - 953295 MB, Free - 640647 MB;
Motherboard: Dell Inc., 088DT1
Antivirus: Windows Defender, Disabled
 

A:Solved: Outlook 2010 insert file

Read other 7 answers
RELEVANCY SCORE 76.8

What I need to do is insert 3 blank rowes in to a my excel sheet before bold text. im having to hand ball it at the moment and the pages are sometimes 18 pages long eg:
1900 - every time there is a bold heading I need to insert 3 blank rows befor the bold text. all the bold headings are in the same column.

Please help if you can, thanx all
 

A:Excel Macro to insert 3 blank rows b4 bold text?

Read other 8 answers
RELEVANCY SCORE 76.8

I've created a macro for a document template. However when it runs the document is populated and the text runs off to the next line. Basically the formatted text wont stay in its proper location. I can manually add the text if the INSert button is on, as it doesnt push the text. Is there a way to incorporate the INSert key into a macro so I wont have this problem? Any other suggestions? The form cannot be modified as its a state form. Thanks.

William
 

Read other answers
RELEVANCY SCORE 75.6

How can I insert a barcode in an MS Word 97/2000 document using a "Macro".

I have a macro like the one I have started on writing below. I am trying to write a bar code into a word doc by using a font and size change. Nothing seems to be working. I can have barcoding font called "True Font" installed on my machine.

Any help out there!!!

Thanks,

Sub BarCode_Writer()
'
' BarCode_Writer Macro
' Macro created 11/13/2001 by mitikavumam
'
ActiveDocument.Select

' possibility 1
'Select and copy the text to the clipboard
ActiveDocument.Bookmarks("\page").Select

'Set the font size
'Selection.Font.Size = txtSize.Text

'Set the font weight etc.
'Selection.Font.Bold = IIf(chkBold.Value = 1, True, False)
'Selection.Font.Italic = IIf(chkItalic.Value = 1, True, False)
'Selection.Font.Underline = IIf(chkUnderline.Value = 1, True, False)

'Set the alignment
'Selection.ParagraphFormat.Alignment = drpJustification.ListIndex ' (combo)

'Type the text
'Selection.TypeText txtTypeText.Text
Selection.InsertAfter vbCr & "PPP" & i & vbCr
'Select and copy the text to the clipboard
'ActiveDocument.Bookmarks("\page").Range.Copy
'App.ActiveDocument.Bookmarks("\StartOfDoc").Range.Copy

' possibility 2
' Position at top of original document
ActiveDocument.Content.Select
Selection.HomeKey Unit:=wdStory
' Append pag... Read more

Read other answers
RELEVANCY SCORE 75.6

Hi,

I want to create a form in Word, which will allow a menu option to insert a new page. The new page will be itself a form.

I have created two templates corresponding to the two forms and set up a menu button to allow a user to insert a new page. It seems to work fine as templates.

When I create a document using the templates, the 'insert' form can't be found. It doesn't have the correct path. I know (well, I've been told!) that I could use the normal.dot template but I don't want to use that if possible. As I will be sending this out to several users I don't want to 'corrupt' there existing normal.dot

Any other ways to define the path?

Any other ways to insert page?

cheers

Oddbod
 

A:Word: insert page using macro

Read other 7 answers
RELEVANCY SCORE 75.6

I need a macro that will insert the file name of Word docs into the top of the Word file. I need all the docs in a given directory to be so inserted.

Thank you in advance for your reply.
 

A:Need Macro To Insert MS Word Doc Filename

Read other 13 answers
RELEVANCY SCORE 74.8

I'm not sure what it is that I am missing but I hit "Record Macro" and go to Insert click on shapes then rectangle. I click on the screen once to put it on there (no specific size) then hit "Stop Recording." But no matter what when I go to look at the code there is nothing there at all. Nothing has been recorded.

I have recorded macros before without any problem. Can someone give me a push in the right direction?
 

A:Word Macro not recording Insert function

Read other 6 answers
RELEVANCY SCORE 74

Hi,
I'm trying to insert a ton of images in Word 2003 and provide a caption for each of these images. I'm trying to come up with a macro that will insert the images but most importantly, to provide a caption for each of them. I have a text file with an array of names for each of the images (in the same order as the images). Could someone give me some guidance as how to insert the caption for each image with the title of the caption matching the name in the array file? .

Thanks!
 

Read other answers
RELEVANCY SCORE 74

In my work environment we are writing test cases and for the test steps we use a word table. Its the same 4 columns so we can load them into the Quality Center environment. One issue we had was our review tool doesn't support word but does text documents. The format of the table was kind of messy when we saved as a text document in the sense it would lump all the stuff together with no clean breaks. As a solution people making every other row and column blank so there would be a break in the text format. Once the review was complete you would have to then go back into that word doc and delete all the blank rows and columns to load into Quality Center. Not hard but time consuming with the number of test we would deal with. I wrote a quick macro that would delete the header in the table plus all the blank rows and columns.

Now what we have is we are re using these test and adding to them. Currently we are pulling them out of quality center, adding the blank rows and columns back in, adding our updates, sending back out for review, deleting the blank rows and columns (macro does this), load back into Quality Center.

There may be a better way to go about this but what I am after is this. A macro that will insert a blank row and column every other row and column. I have been off and on playing with this for a few days but really have gotten no where with it. Posted on a few non technical forum and they suggested posting on this site for some help. I tried searching and did... Read more

Read other answers
RELEVANCY SCORE 74

Hi all,

I'm looking for a way in either Excel or Word 2010 to add text to a line before the text. So, for example I have something like this:

Name1
Name2
Name2
etc..

And then I want to add "1 " before each line in a way that is copy pastable, so it looks like so:

1 Name1
1 Name2
1 Name3
etc..

Is there anyway to do this. it's mostly just to help with copying text from Word/Excel documents onto forums so it formats correctly. Any help at all is much appreciated

Cheers,
Matt
 

A:Solved: Word/Excel 2010 Adding text before each line in a Document

Hi Matt,
It's probably a little cleaner to do it in Excel than in Word, but also a few extra steps. In Word:

You can run a find a replace. Without including the quotes, find "^p" (the paragraph symbol) and replace with "^p1 " (there's a space after the 1). This replaces the paragraph break at the end of each line with another paragraph break and then "1 " at the beginning of the next line. The problem with this method is that the first line won't have a 1 in front of it (because there's no paragraph break before that line) and the last line will have a stray 1 after it. But this should be relatively minor cleanup.

Alternatively, in Excel:

Insert a column to the left of your names. Without including the quotes, enter "1" in the first cell and copy it down your spreadsheet. Insert a column to the right of your names and enter this formula (assuming your names are now in column B):

=A1&" "&B1

This should give you the result you're looking for in column C. Hope that helps.
 

Read other 3 answers
RELEVANCY SCORE 74

I need help with a thank you note I'm creating in Word. In case it's needed I'm running Windows 8.1 and MS Office 2010.

I used an insert text box because initially I created the verse beside the image. Then I moved it down to another page. I will print the first page and put it back in and print the second page so it will open like a card and the text will be oriented properly.

But I'd like to remove the framing lines around the text if possible and can't find a way to do it. These are not gridlines.

It's not terrible that they're there but it would look nicer without them if anyone can help with this.
 

A:Remove Frame from Insert Text Box - Office 2010

Read other 7 answers
RELEVANCY SCORE 73.6

Hi,
Don't mind the curious ones, but I'm one of them. So anyway, almost one year ago now, the Word macro virus W97M/Marker.C was running rampant around Gordon College, with many teachers and students alike being infected. I was even infected with it thanks to one of my professors posting an assignment description document that had it. I was running AVG 9.0 at the time, and it was flagged many a time over. I think there were like six or so instances. My memory may be flaky, as my laptop has undergone many reformats since then, but what I do remember is trying to ignore AVG's warning, due to the fact that AVG has given me many false positives when I used it. The message Word gave me was that the document couldn't be opened because it wasn't available. But the strange part of that is that AVG had not removed anything from the file. I can think of two reasons why the file wouldn't run with the virus in it. Tell me which, if either, is correct. One is that Microsoft has since changed the macro format from 2003 and earlier versions of Word simply due to the many viruses that once existed for it, or two, that message was a very convoluted way of telling me that Windows 7 no longer supports Virtual device Drivers (*.vxd) as I was able to open the file after it had been cleaned up by Eset NOD32. Any knowledge you folks have would be very interesting, as I have always been curious about the very odd weekend of February 12, 2010. Now don't get me ... Read more

A:random curiosity about MS Word macro viruses and why (thank the Lord), they don't work in Word 2007/2010

I don't know the particulars of the macro virus you mention, but with Microsoft Office 2003, a significant change was implemented that effectively stopped the propagation of macro viruses.

Prior to Office 2003, macros were enabled by default, and opening a document with macros and auto-execute meant the macros were automatically executed (and thus the virus could infect and propagate).

With Office 2003, macro security was introduced. With a Microsoft Office 2003 default install, macros need to be signed with a certificate issued by a trusted root CA. Macros that are not signed will not be executed. Users have to explicitly lower the macro security level for unsigned macros to execute. Almost all macro viruses were unsigned.

Read other 3 answers
RELEVANCY SCORE 72.8

Hi
I had a macro running in Word 2007, which simply removed paragraph breaks and replaced them with spaces. It did this for the selected text, and then asked whether the user wanted to continue with the rest of the document. To this I mostly selected NO.
In 2010 the macro replaces throughout the whole document without any prompts. I checked the macro on a Word 2007 machine and the code is the same as the new macro in Word 2010.
Can anyone suggest how to overcome this bug in 2010?
Thanks, Garry

The macro code is below:
Sub RemoveParas()
'
' RemoveParas Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 

Read other answers
RELEVANCY SCORE 72.4

Hello all. Not a regular user of Excel; but do need help in creating something that would be useful to me and a few others at work. I suppose the best way of explaining what I'm after is by giving an example.

I have a directory C:\Users\Tekko\Desktop\Maintenance Project\Cape Nelson
In Cape Nelson are a number of folders named alpha beta charlie delta echo and foxtrot and so on.

I would like to have an excel template in "Cape Nelson" with a macro that when activated names the file as whatever folder name might be in say cell A1 and whatever ever date might be in cell B1. Eg charlie_15-mar-2013.xls
This then is saved in the relevant folder. So in the end I would end up with
C:\Users\Tekko\Desktop\Maintenance Project\Cape Nelson\charlie\charlie_15-mar-2013.xls

Also the macro script would ensure that the macro was disabled in the saved file.

Hoping this is achievable and look forward to replies.
 

A:Solved: Excel 2010 - Macro to name and save file to a specific folder

Read other 16 answers
RELEVANCY SCORE 72

I have a report containing columns of figures, and I would like to have lines drawn above the totals at the bottom of the columns. For reasons that are too complicated to explain here, I'd prefer not to use tables to accomplish this.

It's easy enough to get a solid line above the row of totals, but if I select one of the totals and bring up the "Borders and Shading" dialog, it won't do anything but draw a box around the selected text. The four buttons for top, bottom, left and right all do the same thing, toggling the entire box on and off, when I would expect them to affect only the corresponding segments. If I have no text selected, the entire row of text will get a line, and the buttons function independently.

Is this a bug in Word, or am I missing something?
 

A:Cannot insert lines above selected text in MS Word

Use the drawing toolbar and create a line, place it where you want.
 

Read other 3 answers
RELEVANCY SCORE 71.2

I am stumped, I can do this in Excel, but it is not the same in Word, the code below works as far as brinig up the file open in the Directory that I want, but I can't figure out how to grab the selected filename and assign it to a variable
' Set the default directory.
' Note: Substitute any existing directory.
Options.DefaultFilePath(Path:=wdDocumentsPath) = "\\10.3.16.243\9105_boh"

Dim MyDialog As Dialog
Set MyDialog = Dialogs(wdDialogFileOpen)
MyDialog.Name = "*.txt"
MyDialog.Show
The remainder of the code would be

Documents.Open FileName:="MyFile.txt", ConfirmConversions:=False, ReadOnly:= _
' False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
' "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
' Format:=wdOpenFormatAuto
rest does not matter, but I would guess I need the MyFile.txt to be replaced by the variable, I could not find any good forums on Word VBA

thanks
 

A:Solved: Word macro File Open ...Filename

Read other 7 answers
RELEVANCY SCORE 71.2

Solved!, my final code for getting my version from a java class file is complete!

Code:

Private Funtion GetVersion()
If IO.File.Exists(".\Game.class") Then
Using reader = New IO.StreamReader(".\Game.class")
Dim line = reader.ReadToEnd
Do While line = "" = false
If line.IndexOf("XXyxxY YxxyXX") = true Then
result = line.Substring(line.IndexOf("XXyxxY YxxyXX"))
Debug.WriteLine(result)
Else
Debug.WriteLine("could not find string")
End If
Loop
reader.Close()
End Using
If result = "" = False Then
Dim o As Integer = 0
Dim i As Integer = 20
Do While i > 0
Debug.WriteLine(i)
If IsAlphaNum(result.Substring(i, 1)) = False Then
o = i + 1
i = 0
Else
i = i + 1

End If

Loop
version = result.Substring(20, o - 20)
Debug.WriteLine("version:" & version)
Return version
Else
... Read more

A:Solved: [VisualStudio 2010] - Reading a file for text.

Read other 8 answers
RELEVANCY SCORE 70.8

I am using word 2010 and windows 10 on a Dell Inspiron 5559. I have reinstalled my printer and it's drivers and I have checked that the text colour is not white.
I am having problems with printing word documents. Within a word document any images print fine, as do the lines in a table but no text will print (in any colour).
I can see the text correctly in the word print preview panel.
Even the print test page prints with no text.

Can you help? Thanks
 

A:Word 2010 stopped printing text in word documents

what printer is this this ?
 

Read other 2 answers
RELEVANCY SCORE 70.4

So I have a batch of about 750 Word documents that need to be converted to RTF. I recorded a macro that looks something like this:

quote:

Sub rtf3()
'
' rtf3 Macro
'
'
Documents.Open FileName:="D:\user\Desktop\test\1.docx", ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto, XMLTransform:=""
ActiveDocument.SaveAs FileName:="D:\user\Desktop\test\1.rtf", FileFormat:=wdFormatRTF, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ActiveDocument.Close
It works fine, but there are a couple of problems w/ it. 1, I have to repeat it over and over for each file, and 2, each repetition has to be edited w/ the next filename, the path to that file, and the new filename. I figured out a way to partially automate that process, but it's still a PITA .

Can't I just tell it to get all the .docx files in this folder and all its subfolders and save them as an RTF w/ the original filename?
 

A:Solved: Word 2007 macro to convert file types?

Read other 10 answers
RELEVANCY SCORE 70.4

OMG!!

I am simply trying to search and replace a word in a document to the same word, but a different color. I tried the auto record macro but it does not work. The seach and replace does work when normally editting the text, but the macro will not record BOLD or COLOR changes...why?
this is some of what i have.
Code:

Selection.Find.ClearFormatting
Selection.Find.Highlight = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = False
With Selection.Find
.Text = "MoveL"
.Replacement.Text = "MoveL"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
 

A:Word Macro Color Text

Read other 16 answers
RELEVANCY SCORE 70.4

I need a macro that searches for a specific list of words using the find function in MS Word. For example, if I had a document with 100 recipes in it and I needed to find all the locaitons within the file that had the word flour, oil, or egg in it, this macro would go through and take me to the location of these words. I edit a lot of documents so I spend a lot of time searching for the same words. I basically have a list of about 50 words that I have to run through on each document to check to make sure they correspond to the correct document. The only way I can currently do this is by searching for each word individually...which takes forever. Any ideas or pointers would be appreciated.
 

A:MS Word 2010 macro help

Hi, welcome to the forum,

I helped edit some macro code which searched for specific characters in all the text
http://forums.techguy.org/software-development/1015177-help-vba-word-2010-may.html

You will have to edit the macro to look for oil or whatever,
A table is created at the end with some information about where the text is located.

Maybe some additional editting will work for you.
Take a look and if you need help I'll see if I can figure out more.

I have attached the word doc for you to test.
Just run the macro
 

Read other 3 answers
RELEVANCY SCORE 70.4

Hi,

I've been trying to do this on my own but have been unsuccessful. I need to create 2 macros; one to show/hide certain text and another to automatically update a table of contents when a document is opened.

Any help is appreciated.

Thanks.
 

Read other answers
RELEVANCY SCORE 70.4

Good People,
Add me to the list of people who don't like the new ribbon.

Before with 2007 I could insert a horizontal line of a certain width AND NOT using the auto option where 3 equals turns into a horizontal line. Now in 2010 the most I can get a minimal width horizontal line.

I do not want to use one of the "graphic" selections. How do I put a 5 point horizontal line on a page. I like these simple things as separators.

Please only respond if you have actually done this on WORD 2010.

Oh yes, must clarify I'm working with the beta version of Word 2010.

A:word 2010 insert horizontal line & not automatically

Hello Karl.

On the home tab, expand borders.



Click on horizontal line.



Rt. click the new horizontal line and select format horizontal line.



Should show you this box.



Haven't figured out how to make a dashed or dotted line yet.

Hope this helps.

Read other 9 answers
RELEVANCY SCORE 70

Hi Guys,

I need help creating a dynamic macro that could save me alot of time in the future.

In a nutshell:

- "Name" value in Column A
- "Yes" or "No" value in Column B
- "Name" value in Column C

I need:

- Every cell in Column C to be crossed referenced with Column A
- If there is a match, I need the value in Column B to be changed to Yes

Before:

------Column A ------------------------------ Column B ------------------------------ Column C -------
-------------------------------------------------------------------------------------------------------------------------
-- Jen NO Jen --
-- Jane NO Jane --
-- Sarah NO Sarah --
-- Mike NO James --
-- Mitch NO Fred --
-- Joy NO Lee --
-------------------------------------------------------------------------------------------------------------------------

After:

------Column A ------------------------------ Column B ------------------------------ Column C -------
-------------------------------------------------------------------------------------------------------------------------
-- Jen Yes Jen --
-- Jane Yes Jane --
-- Sarah Yes Sarah --
-- Mike NO James --
-- Mitch NO Fred --
-- Joy NO Lee --
-------------------------------------------------------------------------------------------------------------------------

Thanks for the help,
Ben
 

A:Need Help - Excel 2010 - Macro - Find, if Found Replace Text In Another Column

As just a Formula, put this in column B ' =IF(A1=C1,"Yes","No")'

As a Macro -
Sub MatchReplace()
Dim LastRowColA As String
LastRowColA = Range("A65536").End(xlUp).Row
For i = 1 To LastRowColA
Range("B" & i).Select
ActiveCell = "No"
If ActiveCell.Offset(0, -1) = ActiveCell.Offset(0, 1) Then ActiveCell = "Yes"
Next
End Sub
 

Read other 2 answers
RELEVANCY SCORE 70

We commonly use one of the following placeholders to indicate something to check before completing a document. I would like to build a macro that is initiated when printing or saving that searches for:

? and red text and highlighted text.

I want it to start searching at the beginning of the document and let the document author modify the text or click Next - as he could if the Find routine was run from the drop-down menu.

Can anyone suggest the right code?
 

Read other answers
RELEVANCY SCORE 70

I am trying to write a macro that would will go through my document and delete all the paragraphs that between two words "(CSR)" and "(CSO)". Currently I have to go through and manually do this, which for documents of over 200 pages can mean deleting 10,000s of paragraphs.

I also need to delete all paragraphs that contain the phrase " Type of Company:"

Any help would be appreciated.

 

A:Macro to delete text Word 2007

Read other 6 answers
RELEVANCY SCORE 70

Was wondering if anyone could offer a bit of help on this one - it's been a while since I've worked on macros and I'm struggling to find anything close to this online.

I've got a whole bunch of documents that contain text strings, such as ~[name], ~[gender] etc. These letters are being migrated to a new system that uses MS Word mail merge and as such, I need to convert these from just text place holders into Mail Merge fields. Macroing turning the document into a MM is easy, but it's the replacement I'm having an issue with. They map across to different things so I appreciate I'd have to set what each one would map to, but I'm having trouble since Find and Replace won't insert mail merge fields.

So for instance, I might want to replace all instances of ~[gender] in document with a proper mailmege field of <<sex>>, and then repeat that for 30 or 40 other fields in the letters.

I appreciate this is a bit of an ask, but if anyone has a sec I'd really appreciate it

Cheers.
 

Read other answers
RELEVANCY SCORE 69.6

I have to create reports with about thirty images in them, and I'd hate to keep going through and re-formatting them one by one. I need a macro to run in Word 2010 that does three things: 1) resizes ALL of the images in the document to be 3 inches tall and 4 inches wide, 2) formats all of those images with the Soft Edge Rectangle format 3) give the images the In Front of Text layout. Every time I try to record one, it won't let me select my images once the macro is recording. When I'm not recording, I still can't select more than one image at once (shift + select and ctrl + select didn't work). Any help is greatly appreciated. Thank you!

My laptop's information:
Tech Support Guy System Info Utility version 1.0.0.2
OS Version: Microsoft Windows 7 Home Premium, Service Pack 1, 64 bit
Processor: Intel(R) Celeron(R) CPU 900 @ 2.20GHz, Intel64 Family 6 Model 23 Stepping 10
Processor Count: 1
RAM: 3032 Mb
Graphics Card: Mobile Intel(R) 4 Series Express Chipset Family, 1292 Mb
Hard Drives: C: Total - 223434 MB, Free - 174946 MB;
Motherboard: Dell Inc., 0G848F
Antivirus: Norton Security Suite, Updated and Enabled
 

A:Word 2010 Macro Problem

Hi, welcome to the forum.
I don't have the exact syntax and so for you but Google works wonders.

This is a result of a simple search VBA Word select all images in active documetn.

http://stackoverflow.com/questions/...ro-in-word-to-resize-center-delete-all-images

The code will probably help you on the way.

Happy coding
 

Read other 3 answers
RELEVANCY SCORE 69.6

I am a novice at this and I have searched and searched over the last week trying to figure out a fix to this.

I'm trying to create a Word Macro to remove time from date:

This occurs in 4 different cells.

Cell in Word shows: 05/04/2016 10:00:00

I just need the date to show without the time.

Looking for a code that will make this happen.

Code that I have used for other issues looks something like this, however, the below example is what I'm trying to accomplish:
________________________________________________

Sub TIME()
'
' TIME Macro
'

With Selection.Find

.ClearFormatting
.Text = "??:??:??"
.Replacement.ClearFormatting
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll, Forward:=True, _
Wrap:=wdFindContinue


End With

End Sub
________________________________________________

Any help would be greatly appreciated!

A:MS Office 2010 - Word Macro

Hi & welcome to the Forum.

Instead of using a macro for adding the date you can use Alt+Shift+D instead.

This website may also help you as well.

How to Add the Date and Time to a Word 2010 Document - For Dummies

Read other 1 answers
RELEVANCY SCORE 69.6

Hi all!

I have a MS Word document I need to share with a third party that I need to obfuscate. (We're using a tool from them which seems to have problems with the format of the document, not the contents, and the document is confidential information.)

So, I was trying to write a macro to text substitute words, but haven't quite gotten there yet. I was looking at a thread on this site titled "Word Macro: loop through end of file?", and tried doing something like this:

For Each vWord In ActiveDocument.Words
vWord.Select
Selection.TypeText "=rand()"
Next
End Sub

(Note: I'm not a visual basic expert.... I've done plenty of programming and scripting, but never in Word.)

This didn't really work... I think it was getting hung up on whitespace, and I'm not sure the "=rand()" was doing what was intended. From what I can tell, each vWord contains not only the documents in the words, but the whitespace following the word.

Does anyone have a hint on how this might be done more easily in an automated fashion? The documents are big enough that doing them by hand is not really feasible.

Thanks, Rich
 

A:MS 2010 Word macro - obfuscation

I would probably try and lever the search and replace function. You could try that and use the macro recorder to help you get useful code.
I'm thinking something like this:

Code:
Sub SEARCHREPLACE()
'
' SEARCHREPLACE Macro
ActiveDocument.SaveAs2 ("OB_" & ActiveDocument.Name)
Dim SearchTerm As String

With Selection.Find

SearchTerm = InputBox("Please Type Text to Search for", "Search Term")

.Text = SearchTerm
.Replacement.Text = "**********"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
MsgBox "All instances of the term: " & SearchTerm & vbCrLf & "Will be Obscured", , "Executing"

End Sub

The above code will save a new copy of the file and then present a text box to search for a term, it will replace that term with a row of asterisks. If there are lots of terms you will want it to loop through the searches after the initial duplicate file creation. You might want to feed it a set of terms you want obscuring from another file.
You can muck about with the search criteria if you want it to be case sensitive etc.
 

Read other 1 answers
RELEVANCY SCORE 69.6

Having some problems with the following macro. It prints to the correct trays, but prints in the wrong order (i.e not in the order set out in the macro). Also page 20 doesn't print.
Any ideas how to fix this?
Sub TEST()
Dim sCurrentPrinter As String
Dim sTray As Integer

sCurrentPrinter = ActivePrinter
sTray = Options.DefaultTrayID
ActivePrinter = "HP LaserJet P3010 Series UPD PCL 6"
With Options
.DefaultTrayID = "259"
End With
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="1"
With Options
.DefaultTrayID = sTray
End With
ActivePrinter = sCurrentPrinter

sCurrentPrinter = ActivePrinter
sTray = Options.DefaultTrayID
ActivePrinter = "HP LaserJet P3010 Series UPD PCL 6"
With Options
.DefaultTrayID = "260"
End With
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="2"
With Options
.DefaultTrayID = sTray
End With
ActivePrinter = sCurrentPrinter

sCurrentPrinter = ActivePrinter
sTray = Options.DefaultTrayID
ActivePrinter = "HP LaserJet P3010 Series UPD PCL 6"
With Options
.DefaultTrayID = "259"
End With
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="3"
With Options
.DefaultTrayID = sTray
End With
ActivePrinter = sCurrentPrinter

sCurrentPrinter = ActivePrinter... Read more

A:Word 2010 Prinitng Macro

Hi, welcome to the forum.
I have no idea about why the order is not correct but the fact that Page 20 doesn't print is because the code say Pages:="20"
If you change this to Pages:="20-20" it will probably print Page 20 too.

Maybe if you print one page the code should be Page:="20" ?

About the rest, I have absolutely no idea and no way to test either
 

Read other 1 answers