Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Visual Basic outputs into new blank document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Beth Mc - 20 Jun 2005 14:08 GMT
I saw this macro in another answer. What if I want this macro to list the
bookmarks in a new blank doc instead of printing it out? What would I need to
change the ".printout" to?

Thanks,
Beth

"Jean-Guy Marcil" wrote:

> CMK was telling us:
> CMK nous racontait que :
>
> > I have created 30 or so documents with at least 75 bookmarks in each.
> > Is there any way I can export a bookmark list (TXT) from each
> > document? I need to compare bookmarks between documents and I'm
> > hoping that I don't have to type them all out.
>
> You could try a little macro like this one:
>
> '_______________________________________
> Sub TypeOutBookmarkList()
>
> Dim MyBkmk As Bookmark
> Dim MyList As String
> Dim DocList As Document
> Dim CurDocName As String
>
> With ActiveDocument
>     If .Bookmarks.Count = 0 Then
>         MsgBox "There are no bookmarks in this document."
>         Exit Sub
>     End If
>
>     For Each MyBkmk In .Bookmarks
>         MyList = MyList & MyBkmk.Name & Chr(13)
>     Next
>
>     CurDocName = .Name
> End With
>
> Set DocList = Documents.Add
>
> With DocList
>     .Range.Text = "Here is the list of bookmarks in " _
>         & CurDocName & ":" & Chr(13) & Chr(13) & MyList
>     .PrintOut
>     .Close wdDoNotSaveChanges
> End With
> End Sub
> '_______________________________________
Roger Whitehead - 20 Jun 2005 15:09 GMT
Comment-out or delete the lines:

.Printout                                'To prevent auto-printing
.Close wdDoNotSaveChanges

Signature

HTH
Roger
Shaftesbury (UK)

>I saw this macro in another answer. What if I want this macro to list the
> bookmarks in a new blank doc instead of printing it out? What would I need
[quoted text clipped - 47 lines]
>> End Sub
>> '_______________________________________
Beth Mc - 20 Jun 2005 15:16 GMT
I'm not sure I understand what you wrote. If I don't put in the line
".Printout" will Word automatically open a new blank doc and put the info
into it? And how does the ".Close wdDoNotSaveChanges" help me?

Thanks,
Beth

> Comment-out or delete the lines:
>
[quoted text clipped - 52 lines]
> >> End Sub
> >> '_______________________________________
Roger Whitehead - 20 Jun 2005 15:31 GMT
If I understood you correctly, you want a new document with the Bookmarks
listed. The code you offered did that, but printed the new document, then
closed it without saving:

'***This code adds a blank document-
Set DocList = Documents.Add

With DocList

'***This code Adds text "Here is a list......... etc:
   .Range.Text = "Here is the list of bookmarks in " _
       & CurDocName & ":" & Chr(13) & Chr(13) & MyList

'***This code prints the document
        .PrintOut

'***This code closes the document, without bothering to ask you if you want
to save:
           .Close wdDoNotSaveChanges
End With

Or did I misunderstand? If so sorry, please clarify.
Signature

HTH
Roger
Shaftesbury (UK)

> I'm not sure I understand what you wrote. If I don't put in the line
> ".Printout" will Word automatically open a new blank doc and put the info
[quoted text clipped - 62 lines]
>> >> End Sub
>> >> '_______________________________________
Beth Mc - 20 Jun 2005 16:18 GMT
Roger:
That's perfect. I was just very confused - (hey, it's monday!). Now I've had
my second cuppa and it's making perfect sense. Thanks!!

Beth

> If I understood you correctly, you want a new document with the Bookmarks
> listed. The code you offered did that, but printed the new document, then
[quoted text clipped - 84 lines]
> >> >> End Sub
> >> >> '_______________________________________
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.