Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 15th, 2012, 07:15 PM
kalzin kalzin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 2 kalzin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 16 sec
Reputation Power: 0
Question VB for Word: Macro to Populate Auto-Text

Long story short: I need to be able to list data and have that data populate the Auto-Text in MS Word 2003 via VBS. So far I can manipulate the Auto-Text through the following code, but i need to to read 1 line and insert a Hypertext from a second line.

Code:
Dim p As Paragraph, r As Range, s As String
For Each p In ActiveDocument.Paragraphs
     'Skip empty pgphs, like the one that often finishes a doc!
     If Len(p.Range)  2 Then GoTo nextone
     Set r = p.Range
     r.MoveEnd wdCharacter, -1
     s = Left(r.Text, 32)
     ThisDocument.AttachedTemplate.AutoTextEntries.Add Name:=s, Range:=r
nextone:
Next p
MsgBox "Done"

This one acts line by line. I need One line (first line) to perform as above, I need a second line to be input into a different function. So from above I need to pass this through:

Code:
ThisDocument.AttachedTemplate.AutoTextEntries("cName").Value = _ "Input from line 2 goes here"

cName would pull the data in Line 1 ("s" in previous macro), the input part is Line 2.

goal:
ex1 is auto-text with a "value" of <a href="\\UNC\Path\Exhibit1.pdf">Exhibit 1</a>

I have no idea how to tell it to read line 1 as the first part of the code and then pull the name from 1st part and use it in 2nd part to add the value from the next "paragraph"... any ideas?

Reply With Quote
  #2  
Old June 18th, 2012, 11:04 PM
medialint's Avatar
medialint medialint is offline
Type Cast Exception
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Apr 2004
Location: OAKLAND CA | Adam's Point (Fairyland)
Posts: 14,938 medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)  Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Months 2 Weeks 2 Days 26 m 49 sec
Reputation Power: 8490
Facebook
<edit> wow I was in a foul mood and my comment was very rude and completely uncalled for ... I apologize ...
__________________
medialint.com

“Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss

Last edited by medialint : June 19th, 2012 at 10:02 AM.

Reply With Quote
  #3  
Old June 19th, 2012, 12:35 AM
kalzin kalzin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 2 kalzin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 16 sec
Reputation Power: 0
I didn't mean to steal your code and I do apologize for not giving credit I had no idea where it came from to be honest I was what I had stored many ages ago in my scripts folder for word 2003. I actually ended up using wd functions instead... there is still the question of if it possible to "write-in" the HTML link to a relative file-share such as a UNC path... at present the coding I have works with 2-lines to draw in information but requires that the second line be "Pre-linked".

Any ideas on that?

here's the script that seemed to work pretty well:
Code:
Dim p As Paragraph, s As String
         For Each p In ActiveDocument.Paragraphs
         If Len(p.Range) < 2 Then GoTo next
         Selection.EndKey Unit:=wdLine, Extend:=wdExtend
         s = Selection
         Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdMove
     Selection.EndKey Unit:=wdLine, Extend:=wdExtend
     NormalTemplate.AutoTextEntries.Add Name:=s, Range:=Selection.Range
     Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdMove
next: 
Next p 
MsgBox "Done"  
End Sub

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > VB for Word: Macro to Populate Auto-Text

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap