Word to HTML conversion - Tools/Code
I know there are a few tools out there to convert Word documents to HTML,
but I was wondering if there's an acknowleged "market leader"?
Also, is anyone offering source code for such a tool, and is it any good?
[ Obviously a large part of this "market" is taken by Word's own
save-as-HTML capabilities, but there's always stuff that Word itself won't
do - or won't do in a sufficiently controllable way. ] Tag: importing csv data into Word Tag: 36470
wdDialogFileOpen question
Hey everybody! As a person relatively new to VBA
programming, this newsgroup has been tremendously
helpful. A thank you to everyone who takes the time out
of their day to answer questions!
That being said, here's another one:
I'm trying to build into a custom form a command box that
would allow the user to select a file from their
directories, then have that info including the full path
be filled in to the dialog box. Perhaps code will further
explain:
Private Sub btnBrowse_Click()
With Dialogs(wdDialogFileOpen)
.Display
frmDataSelect.txtSource = .Name
End With
End Sub
"frmDataSelect" would be the custom form and "txtSource"
the text box where the filename is returned. This code
only gives the filename without the path present. Is
there a way I can have the entire file path returned?
-Dave Tag: importing csv data into Word Tag: 36466
Mail Merge Prob
Hi Folks,
I'm using a mail merge form an access database using a simple query to bring
in table data (Medium Time in AM PM format) into a word document. All works
well but I've set up the database for Medium times AM PM format but when the
time is merged with word it shows the time as 24HR Long time e.g. "15:00:00"
instead of the desired "3:30 PM"
There is no VB code behind the document and there is no formatting code in
the databse other than the table design preset.
Any Suggestions??
Cheers
John Tag: importing csv data into Word Tag: 36464
Reading paragraphs and tables in word
I have a word document consisting of paragraphs ans tables which I
want to read through vb.net. I also want to identify when I am reading
paragraphs and when reading tables so that I can perform different
actions with paragraphs and table contents.
I will be thankful to anyone who can help in this regard.
Thanks. Tag: importing csv data into Word Tag: 36460
Centering text
Recently when centering text it centers the entire document, not just the
line I designated to center text on. I have to click on the undo button to
restore the rest of the document to what it was prior to my selection to
center a line of text. Somehow I did something to cause this because it
never worked like that before. Also, I have notice that at times when I do
a ctrl B to highlight text it does the same thing, highlights all of the
text in the document and when I click on undo the rest of the document is
restored to its original unhighlighted appearance. I run Word 2000.
Thanks for your help,
Dean Tag: importing csv data into Word Tag: 36455
Templates, saving, directory
Okay, couple of "simple"?? questions here!
I have created a template - every time I create a
document using this template it gives me a message about
the "normal" template being in use, or changes having
been made - I'm guessing this has something to do with
the way in which my seperate, other, template was
created - how do I correct this?
Also, anytime a user uses this template, I would like the
document to be saved in a specific document - is that
something I can "build" into the template?? Or, how
could I code that in using VB.
And the last question, I would like to create a default
for the file name to reference a bookmark that I have
created. I had some code (based in Access) which was
doing this, but that created more problems. This again
will always be the case on any document created with this
same template - any way to build all of this in the
template - or a macro which is executed upon use of this
template??
I haven't used VBA within word before and am actually
very new to VB anyway - so please forgive my ignorance!
In case it makes a difference - the document is being
generated by automation from Access.
THANKS! Tag: importing csv data into Word Tag: 36443
Removal of Password Protection
hi
I have written a VB program which converts the doc file
into a txt file.It does it silently. i mean the Visible
property of the word application object is set to false.
The DisplayAlerts property is also set to false.
The Problem :
If a doc file is password protect (modify or Open)a dialog
box pops up and waits for password i do not want this
password to pop up ? how do i convert? is there a way in
which i can do it silently ?
if not i want this dialog boxes to come to front of all
other applications.
regards
maneesh Tag: importing csv data into Word Tag: 36442
VBA and bookmark in a textbox in header/footer
I have a template for 20 different localoffice. The user=20
choose in a form which office they belong and then click=20
OK and it will be correct inserted in the pagehader. I=20
have all officeaddress as autotext, the code choose=20
correct address and put it in the textbox with this code:
ActiveDocument.Bookmarks("dn_Adress").Select
SaveSetting "DN", "Configuration", "DefaultAdress",=20
Me.CombAdresser.Text
Select Case Me.CombAdresser.Text
Case "Falun" '/Falun
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_Falun").Insert Selection.Range, True
Case "G=E4vle" '/G=E4vle
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_G=E4vle").Insert Selection.Range, True.
The bookmark is placed in pageheader in a textbox.
My very big problem is that I must reload the userform to=20
let the user change the address and when I do that will=20
the new officeaddress appear after the first one, I need=20
help how I can select and replace the text with the new=20
address. Can anyone help me with this?
Thanks for any help
Camilla Tag: importing csv data into Word Tag: 36433
Auto open macro
I would like to have a macro run when I open a Word
document. In Excel you just need to name the macro
Auto_Open. What do I need to do in Word?
Any help would be appreciated.
Jim Tag: importing csv data into Word Tag: 36430
Macro question
I am trying to record a macro that will display a
letterhead with a particular font, size, etc. When I
record the macro:
1. I change the font, font size, and turn Bold on.
2. I type what I want my letterhead to display.
3. I enter a couple blank lines.
4. I stop recording.
When I run this macro on a new document, the only
attribute that carries over is the bold. I thought Word
recorded all mouse clicks in the toolbar. I don't want
users to manually enter the font and font size in the VB
code every time one of them wants to create a macro like
this. Is there any way to solve this problem? Thanks.
Derek Jones
Software Support Specialist
Shenandoah University Tag: importing csv data into Word Tag: 36429
information property
I'm trying to get the total pages in a document but the
procedure doesn't always give me the right number. Though
I have noticed that if I step through the code manually it
works!
Any knowledger regarding this?
Thank you very much,
Edward
ps. you may email me if you know something Tag: importing csv data into Word Tag: 36428
FormFields in a table Strange bookmark naming problems
I am working with Word 2002.
I have a table (2 columns wide), that has two empty
FormFields. When a user enters information in one of the
form fields, an exit macro is run, and a new row in the
table is created with new empty FormFields.
This all works fine. The problem is that I want Word to
give the newly created FormFields a bookmark name of my
choice.
In this 2 column table, two FormFields are created when
the exit macro is run, but only the FormField on the left
column has the bookmark applied to it. The bookmark for
the FormField in the right column remains blank.
HOWEVER, if I try to name the bookmark in the right column
first, and then the one in the left column second (see
code below), both than have their bookmarks names applied.
The only difference is the order in the code. For ex.
===============================================
Sub addrow()
Dim rownum As Integer
ActiveDocument.Unprotect
ActiveDocument.Tables(5).Rows.Add
rownum = ActiveDocument.Tables(5).Rows.Count
ActiveDocument.FormFields.Add Range:=ActiveDocument.Tables
(5).Cell(rownum, 2).Range, Type:=wdFieldFormTextInput
'BOOKMARK BEING APPLIED
ActiveDocument.Tables(5).Cell(rownum, 2).Range.FormFields
(1).Name = "ForeignEmployees" & rownum
ActiveDocument.FormFields.Add Range:=ActiveDocument.Tables
(5).Cell(rownum, 1).Range, Type:=wdFieldFormTextInput
' BOOKMARK BEING APPLIED
ActiveDocument.Tables(5).Cell(rownum, 1).Range.FormFields
(1).Name = "ForeignCountries" & rownum
ActiveDocument.Tables(5).Cell(rownum, 1).Range.FormFields
(1).ExitMacro = "addrow"
ActiveDocument.Tables(5).Cell(rownum, 1).Range.FormFields
(1).Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True
End Sub
===========================================
The above code works, however if I switch order in which
the FormFields are named, only the left column FormField
is named, and the right one is blank.
===========================================
Sub addrow()
Dim rownum As Integer
ActiveDocument.Unprotect
ActiveDocument.Tables(5).Rows.Add
rownum = ActiveDocument.Tables(5).Rows.Count
ActiveDocument.FormFields.Add Range:=ActiveDocument.Tables
(5).Cell(rownum, 1).Range, Type:=wdFieldFormTextInput
' BOOKMARK BEING APPLIED TO LEFT COLUMN
ActiveDocument.Tables(5).Cell(rownum, 1).Range.FormFields
(1).Name = "ForeignCountries" & rownum
ActiveDocument.FormFields.Add Range:=ActiveDocument.Tables
(5).Cell(rownum, 2).Range, Type:=wdFieldFormTextInput
'BOOKMARK BEING APPLIED TO RIGHT COLUMN
ActiveDocument.Tables(5).Cell(rownum, 2).Range.FormFields
(1).Name = "ForeignEmployees" & rownum
ActiveDocument.Tables(5).Cell(rownum, 1).Range.FormFields
(1).ExitMacro = "addrow"
ActiveDocument.Tables(5).Cell(rownum, 1).Range.FormFields
(1).Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True
End Sub
========================================
The above does not work correctly.
So, while the first subroutine was able to make the
program correctly, the quirkiness of this solution leaves
me confused. My problem now, is that I also have a table
with 3 columns that needs to work the same way, but no
matter which order I name the FormFields in the new row, I
can never have the name applied to the FormField in the
rightmost column.
I am guessing that the solution lies somewhere in the way
the bookmark name is applied. I hope someone can shed some
light on this situation. Thanks.
-Robert Tag: importing csv data into Word Tag: 36422
Finding out the type of control
I have a userform with various controls in it. I iterate
the controls with with "For Each ctl in
ActiveDocument.Userform.Controls..."
How can I find out, what type that control is (ie.
textbox)? In other words, how can I go trough all
textboxes but not other controls? I know, that is should
be quite easy, but I can't work it out easily...
Thanks for any help.
JJ Tag: importing csv data into Word Tag: 36420
WORD Viewer problem using VBA and VB 6.0
Hello,
I have an interesting problem for the knowledgable vb/vba programmers
out there. I am using VB 6.0 with a reference to the Microsoft Word
8.0 Object Library. I am generating a Word document with VB 6.0 and
opening the document in Word Viewer using the shell command.
Everything works fine, but after the document is open, it takes 3 or 4
clicks on the close(X) button to get the viewer to respond and close.
The same applies when clicking on the file menu within the viewer.
Has anyone experienced this problem that can give me a solution. I
would like experienced responses only. No "guess" answers! Here is
the tail portion of the code: Thanks in advance!
' Insert number of pages into report header
intNumPages = wordApp.ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
wordApp.ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
wordSelection.MoveRight , 10 ' move position to after Page x of
wordSelection.TypeText intNumPages
' Save doc
wordDoc.SaveAs strDocPath
wordDoc.Close
wordApp.Application.Quit
' Destroy objects
Set wordDoc = Nothing
Set wordSelection = Nothing
Set wordApp = Nothing
' Open doc file with Word viewer
strQuotes = """"
lngShell = Shell(strWordPath & strQuotes & strDocPath & strQuotes,
vbNormalFocus)
DoEvents Tag: importing csv data into Word Tag: 36418
Allowing font formating in a protected document
Is it possible to allow a user to enter text into a
protected document form field and then allow them to
selectively format specific words? (i.e. to use functions
such as Bold and Underline) Tag: importing csv data into Word Tag: 36402
Deleted macros but still getting warning
I posted the question below a couple of weeks ago.
=======================
I created some macros in a Word template 'MyTemplate.dot'.
I have then moved all of those macros to my 'normal.dot'
template.
No macro appears for 'MyTemplate.dot' in the list when I
select Tools...Macro...Macros (or Alt F8).
Also, if I look at the project in the VB editor there is
no 'Modules' folder under TemplateProject 'MyTemplate'.
However when I close and re-open 'MyTemplate.dot' I still
get presented with the warning dialog stating that
"The document you are opening contains macros or
customizations".
How can I get Word to recognise that all of the macros
have been renoved?
Thanks in advance
=======================
I got a direct reply from Doug (thanks, Doug!) which
stated the following:
=======================
In the normal course of things, you would should not be
opening the template,
rather, select New from the File menu and then select the
template as the
basis of the document that you want to create. You would
not then get the
warning.
=======================
However, this is not the case. Even when I open a new
document based on the template I get the warning message
about macros. This is in spite of the fact that there are
no macros (that I can identify anyway) in the document.
Can anyone shed any light? Tag: importing csv data into Word Tag: 36398
Spell Checking a Protected Document
I have created a form in word and have locked it so that
the user can only change the fileds and not the field
headings.
I have a text field which is about 200 chars of free text
and i want the user to be able to spell check it after
they have typed it. I created a command button and
allocated it the following code -
"Application.ResetIgnoreAll
ActiveDocument.SpellingChecked = False
ActiveDocument.CheckSpelling"
Which i got from VB Help. The problem is the code stops as
the form is protected. How can i get around this. Really i
would just like the spell check to be on the one text
field not the entire form as well.
I am using Word 2000 and Visual Basic 6.0 Tag: importing csv data into Word Tag: 36397
How to stop user from changing some options
Hi,
I am writing VBA code to turn off some options which are causing trouble
during the down-stream operations on Word document, such as
AutoFormatReplaceFractions. I am planning to associate my code with some
events such as Open doc, New doc, etc. However, after a document is openned
or created, the users can still use the Tools->Options, or
Format->AutoFormat->Options to change these options. I cannot totally
disable these Word commands since the users are still allowed to changes
othere options. Is there a way I can prevent users doing this?
Thanks in advance for your help.
Ken Tag: importing csv data into Word Tag: 36391
Insert Office 2K Clipart
I have a macro in Word XP that inserts clipart from Office 2000 Clip
gallery:
Selection.InlineShapes.AddOLEObject ClassType:="MS_ClipArt_Gallery.5"
On execution it causes a run-time error '4198' Command failed.
What is this error caused by?
Cheers Tag: importing csv data into Word Tag: 36388
Word Application Object
I have a question regarding what happens when the user
hits the "X" (on the top right hand of the Word Window)
to close a Word application. Using
dim wapp as new word.application()
It seems pretty clear that if the user clicks on the X
then the statement (wapp is nothing) should be true and
this is not the case.
*CODE*****
If Not (wapp Is Nothing) Then
If wapp.Documents.Count > 0 Then
Dim intResponse As Integer
If myDoc.Saved <> True Then
...more code
****end code*************
Programs execution executes the code inside the if
statement above and it crashes on wapp.documents.count>0
The Following error is thrown "the RPC server is
unavailable".
NOTE: Please note that my program initially opens a Word
application and types stuff into it. I then manually
close the Word Application (as any curious client might)
and then i run my program again which runs the code
snippet above. This crashing is what i am trying to avoid
and i am kinda' stuck cause i don't know what the X does
in the first place and why is wapp not null when the x is
pressed. THanks for the help.
Gabriel Tag: importing csv data into Word Tag: 36383
counting a character
Without using Find/Replace (whether manually or in a macro), is there a
vba way of determining how many times a certain character appears in a
selection?
Larry Tag: importing csv data into Word Tag: 36374
Deleting Blocks of words
I have Office XP. In Microsoft Word I can't delete several
words without it asking me if I am sure I want to delete
them. How can I turn this off so that when I select
Delete, it deletes the highlighted words without asking?
Thanks Tag: importing csv data into Word Tag: 36367
Word wants to install - though its already installed
Anyone with experience with Word stating up with a
message saying it is preparing to install Word. Press
cancel and word starts up, though it looks a bit
different then it use to.
Thanks for any help, Leo Tag: importing csv data into Word Tag: 36358
Mailmerge in Word2000 from Outlook 2000
Hello,
I want to create a Word Template that lets me print
address labels for contacts in a Public Contacts folder.
I tried with a loop that filled an Excel sheet or Word
table with the contacts and then MailMerge on the
sheet/table, but it only seems to work on the machine I
record it...
Any advice is appreciated!
TiA,
Kristian Tag: importing csv data into Word Tag: 36354
FileSave makes me crazy !!
Hi All,
Using Word 2002, in a large and complex add-in (loaded with the
/L-commandline switch) I have a class module to intercept events and
modules with a lot of routines. One of the (public) routines is
FileSave() and in the class module I also intercept the
DocumentBeforeSave.
I have the following strange behaviour:
When Closing the document (also intercepted) and Word QUIT
(intercepted) and the document not saved: my specific FileSave is
nicely executed, after the DocumentBeforeSave event.
But (and this is the problem): when explicitly clicking the default
Save button (on the default Word-toolbar) or using the File-->Save
menu it does not execute FileSave.
What happens is the following;
The first time I press <Save> I see that the document is being saved
(simply see it happen on the screen and see the file time-stamp): The
LOG-file just shows:
11-08-03 14:40:01 DocumentBeforeSave start
11-08-03 14:40:01 WHT007000.TMP .saved: False
11-08-03 14:40:01 DocumentBeforeSave end
So the FileSave-routine is not executed while the file is saved (as
should be: doc.saved = False) !!! (I also update an Oracle database
with SetExpId in the FileSave and this did not happen)
The second atime the LOG-file shows:
11-08-03 14:40:04 DocumentBeforeSave start
11-08-03 14:40:04 WHT007000.TMP .saved: True
11-08-03 14:40:04 DocumentBeforeSave end
indicating that (indeeed the first time the document is really saved (
doc.saved = True)
Typing something in the document (.saved to become False now) en
pressing File-->Save shows on the screen the saving be done and in the
LOG-file:
11-08-03 14:40:10 DocumentBeforeSave start
11-08-03 14:40:10 WHT007000.TMP .saved: False (correct)
11-08-03 14:40:10 DocumentBeforeSave end
Since the first "real command" in FileSave is writing to the LOG-file
I should at least see a line with "<time-stamp> FileSave start" in the
LOG-file
This makes me ccompletely crazy: Why is the FileSave not executed???
I would be very pleased if someone can help me out.
Best regards,
Hans Troost
My DocumentBeforeSave is this:
Private Sub ActiveApp_DocumentBeforeSave(ByVal Doc As Document,
SaveAsUI As Boolean, Cancel As Boolean)
<write to LOG-file> "DocumentBeforeSave start"
<write to LOG-file> Doc.Name & " .saved: " & IIf(Doc.Saved,
"True", "False")
<write to LOG-file> "DocumentBeforeSave end"
End sub
and FileSave:
'
' FileSave Macro: intercepts the regular word SAVE command
' Saves the active document or template
'
Dim strDocFullName As String
Dim strDocName As String
Dim strExpID As String
'
' FileSave Macro: intercepts the regular word SAVE command
' Saves the active document or template
'
Dim strDocFullName As String
Dim strDocName As String
Dim strExpID As String
<write to LOG-file> "FileSave start"
<write to LOG-file> "File to be saved: " & ActiveDocument.FullName
<write to LOG-file> "Re-open: " & IIf(blnReOpen, "True", "False")
strDocFullName = ActiveDocument.FullName
strDocName = ActiveDocument.Name
If blnReOpen Then
With frmTMP2Doc
.lblInfo.Caption = "First time saving of experiment " &
Left(strDocName, 9) _
& vbNewLine & vbNewLine _
& "The document will be closed and re-opened"
.Show
End With
End If
ActiveDocument.Save
If IsHellasDoc(ActiveDocument) And Right(strDocName, 4) = ".TMP"
Then
ActiveDocument.Close
Call MyFileCopy(strDocFullName, gcolSettings(gcstrWorkDir) &
Left(strDocName, 9) & ".doc")
Call Kill(strDocFullName)
Call SetExpId ' increase the LastExp field in table
HELLAS_USERS in the database
If blnReOpen Then
Call DoOpenExp(Left(strDocName, 9) & ".doc",
gcolSettings(gcstrWorkDir))
End If
End If
If blnReOpen Then
Unload frmTMP2Doc
End If
<write to LOG-file> "FileSave end"
End Sub Tag: importing csv data into Word Tag: 36349
Reading multiple documents' word count
Hello,
I have a folder with about 20 word documents and I would
like to find out how many words are in all of the documents
combined w/out referencing to each file explicty i.e 1.doc
2.doc rather something to the extent of *.doc .
I hope you know what it is that I'm trying to say
and output this to anywhere msgbox or a text file or write
it to the active document.
Thank You,
Den Tag: importing csv data into Word Tag: 36304
assign a macro to a toolbar button
The help text indicates that you can assign a macro to a
button on a toolbar. I am unable to determine how one can
get a blank button onto the toolbar to which a macro can
be assigned. In excel, no problem,
Customize/Command/Macro gives you a smiley face custom
button to drag up to a toolbar. Tag: importing csv data into Word Tag: 36296
Problem with difference between sentences and lines
Hi,
With the help of some of you I am able to read word (in-line) comment with
page and line numbers.
I can store it and put it back in a document again.
I have even fixed the problem with shifting lines (and pages) after comment
insert.
But I have another problem.
Reading comment is page, line related, inserting is Sentence related.
(Reading must stay page, line related for 'other' reasons!)
There are times when there are 2 sentences on 1 line.
In that case my comment indicator is (sometimes?) visible on the next/wrong
line.
The frequency of occurrence is limited, so it is no big issue, but I like it
to be perfect.
So the simple question now is:
How can I step thru a word document using lines numbers?
(and still insert my comment using line numbers)
Regards Peter Tag: importing csv data into Word Tag: 36283
firing event when word application closes
I have been reading up on how to fire events on vb when
documents open/close and also when the word application
quits... i have also read the document
http://www.mvps.org/word/FAQs/MacrosVBA/PseudoBeforeClose.
htm
which talks about the bug in the DocumentBeforeClose
event. My main problem is that i need to somehow know
when the user closes (hits on the x) the word
application. I have some code checking to see if
documents are open if so, it closes them.
in variable declaration on top..
(dim withevents wapp as new word.application)
in some method.
If wapp.Documents.Count > 0 Then
wapp.Documents.Close
(Word.WdSaveOptions.wdDoNotSaveChanges,
Word.WdOriginalFormat.wdWordDocument, False)
End If
********
the problem is thus the following if the user closes the
word application then the wapp.documents.count>0 will
give me an error( the RPC server is unavailable) since
their is no wapp object in the first place. I need to
know when the user closes the wapp application so i can
start it up again or bypass some lines of code...
Again, the article found here
(http://www.mvps.org/word/FAQs/MacrosVBA/PseudoBeforeClose
.htm
) has a way around this problem but i have used to code
and set breakpoints and i never seem to hit them--> event
now being fired on method...
THanks, a lot.
ps there are a lot of mistakes in msn library (html bugs)
search for example the documentBeforeClose event :~>
gabe Tag: importing csv data into Word Tag: 36282
All textboxes on the current page
OK, so Word has no page object, but I need one anyway. ;)
Is this the most efficient way to operate on all of the textboxes
whose anchors are on the current page?
Dim sh As Shape, r As Range
Set r = Selection.Range
Set r = r.GoTo(What:=wdGoToBookmark, Name:="\page")
r.Select
If r.ShapeRange.Count = 0 Then MsgBox "No shapes.": Exit Sub
For Each sh In ActiveDocument.Shapes
If sh.Type = msoTextBox Then
If sh.Anchor.InRange(r) Then _
sh.TextFrame.TextRange.InsertBefore "Z"
End If
Next
TIA
--
Mark Tangard <Mark@Tangard.com>, Microsoft Word MVP
"Life is nothing if you're not obsessed." --John Waters Tag: importing csv data into Word Tag: 36280
How to stop users create nested tables? Possible
Hi,
The organization I worked for would like stop users create nested tables.
Can this be done with VBA code? Any suggestions will be greatly appreciated.
Ken Tag: importing csv data into Word Tag: 36279
error 462 remote server does not exist
I have office XP and used the code from the KB article to
sent the current Access XP record to Word using
Automation: http://support.microsoft.com/default.aspx?
scid=KB;EN-US;q210271&
Once in awhile, one user gets the error 462 remote server
does not exist or is unavailable. In my code, I do not
quit Word because the user needs to preview and print the
doc. She then closes the Word and not save the file. At
this point is when the error happens. This problem is not
happening on any other computer.
I've done a search thru google about this error and read
about issues one may run into using early binding and
about Automation Error Calling Unqualified Method or
Property (http://support.microsoft.com/default.aspx?
scid=kb;EN-US;189618).
I'm not quite sure where to fix the problem in my code,
and why only one user is having this problem. Please
help! Below is a snippet of the code:
Private Sub prevletter_Click()
On Error GoTo err_prevletter
Dim filepath, strDocName As String
Dim objWord As Word.Application
Dim wdDoc As Word.Document
filepath = "O:\Databases\Documents\Complaints\"
strDocName = "CompResponse" & F!LetterVersion & ".dot"
' Start Microsoft Word.
Set objWord = CreateObject("Word.Application")
Set wdDoc = objWord.Documents.Add(filepath & strDocName)
With objWord
' Make the application visible.
.Visible = True
' Move to each bookmark and insert text from the
form.
.ActiveDocument.Bookmarks("SentDate").Select
.Selection.Text = (Format(F!SentDate, "mmmm d,
yyyy"))
.ActiveDocument.Bookmarks("FirstName").Select
.Selection.Text = (CStr(F2!FirstName))
.ActiveDocument.Bookmarks("LastName").Select
.Selection.Text = (CStr(F2!LastName))
...
End With
Set wdDoc = Nothing
Set objWord = Nothing
Exit Sub
exit_prevLetter:
objWord.Quit
Set wdDoc = Nothing
Set objWord = Nothing
Exit Sub
err_prevletter:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
Else
MsgBox Err.Number & vbCr & Err.Description
End If
Resume exit_prevLetter
End Sub Tag: importing csv data into Word Tag: 36266
inserting blank line
Is there a way to search through a document and insert a
blank row above the row that you found a specifiv word in?
For example:
Name:
Chad Lucy
Address:
123 sesame street
Phone Number:
111-222-3333
I would like to insert a blank row above address and phone
number.
Thanks
Chad Tag: importing csv data into Word Tag: 36265
Email!
Am thinking of using MSWord to send (email) the created
document via application.
I'd appreciate your input regarding pros/cons of this
approach and also some sample code to start me with.
regardds Tag: importing csv data into Word Tag: 36264
Normal.dot really big
A couple of years ago, when the Normal.dot in my Word 97 was about 600
KB, I asked how big a Normal.dot was too big, and was told that even
twice that size was no problem. As the number of my macros keeps
increasing, so does the size of Normal--now it's up to 1.42 MB. Plus I
have a global add-in template of about 1 MB. Also, I occasionally run
the Word Code Cleaner. (The tootal number of macros in the two
templates is ... 400).
Is this a problem? Word seems to function normally. The only problem
is that occasionally I'll be working on a document and Word will freeze
up, forcing me to shut it down from the Close Program dialog box.
Larry Tag: importing csv data into Word Tag: 36254
Slowing down code execution
How do I slow down the execution of code in VBA without
having to press F8 each time? I want to view the code
execute slowly. Is there a timer command I can use to do
this? Tag: importing csv data into Word Tag: 36243
Commandbar disapear
Hi,
I made a commandbar in at template to activate a form. This works fine, but
you can only run the form once in the template and I would therefore delete
the commandbar when activating the form. This works also fine - BUT now, I
got problems - because next time I activate the template, the commandbar is
gone...
I have tried different codelines like:
'ActiveDocument.CommandBars("Afregning").Visible = False
'CustomizationContext = ActiveDocument
'CommandBars("Afregning").Visible = False
But the Commandbar will not only disapear in the current document.
Do anyone know the code or reason? I cannot use autonew or anything starting
with the template cause the the template is starting up in IE, and that do
not work.
Hope for answers
Lone Tag: importing csv data into Word Tag: 36242
Write diectly to a text file with VBA
Hi,
I am trying to write VBA code to process Word documents and save the
contents to a text file. If I use SaveAs a text file, all layout information
of tables will be lost. Is there a way that I can open a text file and write
to it within VBA code?
Any help will be greatly appreciated.
Ken Tag: importing csv data into Word Tag: 36216
Use of Find object
Hi
I have code in a VB6 application like this:
Dim oFind As Find
Set oFind = .Tables(1).Rows(1)Range.Find
With oFind
.Forward = True
.Text = "CR"
.Replacement.Text = "^p"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
The code inside the With statement would not execute until
I changed the data type for oFind to type Object, like
this:
Dim oFind As Object
My question: Why wouldn't this work with oFind declared as
type "Find"?
Thanks Tag: importing csv data into Word Tag: 36209
Removing and replacing paragraph marks
Hi,
I am creating a macro that will take a text file of many
records separated by section breaks. This file comes from
Wordperfect, so instead if Endfields, I have paragraph
marks. I need to make this file into a data source for
different shell docs. So far I have a macro that replaces
all the paragraph marks with tab characters (I would use
commas, but there are commas in the records already for
monetary amounts), then the macro replaces each section
break with a paragraph mark. Finally, the macro types the
fields that will be used as the headings for the data
source. The only problem I am running into now is that
the final data field has a paragraph marker after it, so
when I have that replaced with a tab character it produces
more fields than are in the header. This is a problem
with the final merge because it says there are too many
fields. Is there a way create a macro that will go to the
final line of the record and remove only that one
paragraph marker while keeping the section break? Here is
what it looks like before conversion:
046<p>
Mr. John Doe, Superintendent<p>
Community Unit School District 1<p>
1212 State<p>
Springfield, MO 62360<p>
<p>
Hannel<p>
772-001-003/S03<p>
construction of an addition to the Elementary School for
160 students in PreK-6th grades, along with health, life-
safety improvements to the 1917 and 1921 portions of the
school determined to be functionally over 100 years old<p>
#,###,553<p>
#,###,031<p>
###,522<p>
01 elementary grant index of .733019<p>
093<p>
47<p>
Adams<p>
Payson Community Unit School District 1<p><section break>
The macro I have created so far converts the file into this
Field1<t>Field2<t>Field3<t>, and so on
Mr.John Doe, Superintendant<t>Community School<t>and so on
The files range in size from 11 records to 73. Any help
would be much appreciate.
TIA,
Jason Tag: importing csv data into Word Tag: 36205
Microsoft in Detroit?
Found this while browsing the other day... thought I'd
share it with the ng... enjoy!
HTH,
Richard Choate
Microsoft in Detroit?
At a recent computer expo (COMDEX), Bill Gates reportedly
compared the computer industry with the auto industry and
stated "If GM had kept up with technology like the
computer industry has, we would all be driving $25 cars
that got 1000 mi/gal." Recently General Motors addressed
this comment by releasing the statement "Yes, but would
you want your car to crash twice a day?" and also noted
the following consequences of GM imitating Microsoft:
1. Every time they repainted the lines on the road you
would have to buy a new car.
2. Occasionally your car would die on the freeway for no
reason, and you would just accept this, restart and drive
on.
3. Occasionally, executing a maneuver would cause your car
to stop and fail and you would have to re-install the
engine. For some strange reason, you would accept this too.
4. You could only have one person in the car at a time,
unless you bought "Car95" or "CarNT". But, then you would
have to buy more seats.
5. Macintosh would make a car that was powered by the sun,
was reliable, five times as fast, twice as easy to drive,
but would only run on five percent of the roads.
6. The Macintosh car owners would get expensive Microsoft
upgrades to their cars, which would make their cars run
much slower.
7. The oil, gas and alternator warning lights would be
replaced by a single "general car fault" warning light.
8. New seats would force everyone to have the same size
butt.
9. The airbag system would say "are you sure?" before
going off.
10. If you were involved in a crash, you would have no
idea what happened. Tag: importing csv data into Word Tag: 36202
Break sub menu is missing from Insert pull down menu
When I click on the pull down menu "Insert" the "Break"
sub menu is no longe there. It is usually at the top of
the list. Can anyone help me restore this submenu? The
items in the custom menu do not include this entire sub
menu.
Thanks
Marty Tag: importing csv data into Word Tag: 36200
Office Automation - starting Word from Access
I'm trying to do a mail-merge from Access, but with Word running on a
separate server (using dcomcnfg to cause Word to be started remotely).
I can start the Word remotely in server mode using the following
code:
Dim wobj As Word.Application
Set wobj = CreateObject ("Word.Application")
but I can't connect to a running object using the GetObject method:
Set wobj = GetObject(, "Word.Application")
It returns error 429. Has anyone seen something like this previously?
Thanks in advance,
Ken Tag: importing csv data into Word Tag: 36197
close old document macro
I have a form that saves the file using the value from a
variable as the name. Now I want to be able to open
(already have that working) a new doc based on a .dot I
want to then close the previous file. I don't know how to
pass the variable value onto the close command here is
what I have so far
Documents.Add Template:= _
"\\Server\Share\forms\templates\Full page
Scans2.dot", NewTemplate:= _
False, DocumentType:=0
Windows(ActiveDocument.FormFields
("Text1").Result).Activate
ActiveDocument.Close
End Sub Tag: importing csv data into Word Tag: 36196
End of Cell call command
Is there a command to position the insertion point at the
end of a table cell?
TIA,
Dave Tag: importing csv data into Word Tag: 36195
Insert Shape in multiple Headers
Hi,
I'm working on a vba macro (which will be used with a
UserForm) that will insert a text box in the all headers.
The headers will already have shapes or text located in
them so I do not want that text to be deleted. Basically
I have Different First page and no other sections. So I
want the box to appear in the Different First Page and
Primary Headers. I hope I don't have to create two macros
in order to have the textbox appear in multiple sections.
or do I? I also noticed that if I don't use the If stmt
and only say wdHeaderFooterPrimary, then it will only
insert the textbox on the current page header and I then
have to go to the first page and run the macro again for
that page. ;o(
Well, Headers will be the death of me yet. All
suggestions are welcome and most appreciated!!
Thank you
Kerri
Here is a trimed down version of my macro.
Sub SideAddress()
If ActiveWindow.View.SeekView = wdHeaderFooterPrimary =
True Then
Resume
Else: ActiveWindow.View.SeekView = wdSeekFirstPageHeader
End If
Set Textbox1 = Selection.HeaderFooter.Shapes.AddTextbox
(msoTextOrientationHorizontal, _
18#, 360#, 72#, 72#)
'I left out the formatting of textbox since that wasn't
the issue.
'Insert text into the textbox
Textbox1.Select
With Selection
.TypeText Text:="Name"
.TypeParagraph
.TypeText Text:="Address"
End With
'Activate Main document when finished with header
ActiveWindow.View.SeekView = wdSeekMainDocument
End Sub Tag: importing csv data into Word Tag: 36194
Document text to email
Can anyone help please?
I am wanting know whether it is possible progammatically
to copy the text of a WORD document into an email message
without having to press edit & paste in the email message
to place the copied text into the message.
I can get the text to the clipboard with the following but
need that bit extra :-)
Selection.wholestory
selection.copy
Kind regards
Mark Tag: importing csv data into Word Tag: 36187
Sending fields Word from VB.NET
How do I sent information to word from a program in
Visual Basic (2003)? For example, when calling word with
the Shell command. In particallar I would like to pass
an array to Word to be use to fillin information in a
template.
Neal Tag: importing csv data into Word Tag: 36183
Run-time error '4198'
I have installed MS Clip gallery from Office 2K so that I can use the clip
art in Office XP SP-2.
I want to setup a macro which is run from the menu so that I do not have to
go through the tedious Insert>Object>Microsoft Clip Gallery procedure for
inserting the 2K clipart.
I have the following macro in MS Word which causes a run-time error '4198'
Command failed, when the macro is run:
Selection.InlineShapes.AddOLEObject ClassType:="MS_ClipArt_Gallery.5"
How can I stop this error from occurring?
Cheers Tag: importing csv data into Word Tag: 36181
I would like to create a Word document from a csv file.
Does anyone know how to do this?
Thank you.
Doreen