adding variable in document.add line 
Author Message
 adding variable in document.add line

I'm using a listbox to show all templates in a directory
and want the user to be able to double click an item in
the listbox (i.e. the desired template), which then opens.
I'm recording the value of the selected listbox item into
a variable and want to insert that variable in the
document.add line. I just don't know the exact way to do
it. Who can help?! Thanks!

The Code:

Private Sub ListBox1_DblClick(ByVal Cancel As
MSForms.ReturnBoolean)
Dim selected As String
selected = ListBox1.Value
Documents.Add Template:="\\SERVER01\templates\[place where
the 'selected'-variable should go]", _
        NewTemplate:=False, DocumentType:=0
End Sub



Sun, 31 Oct 2004 18:04:00 GMT  
 adding variable in document.add line
Hi there!

Sorry for taking all this space in the newsgroup, but I
solved my own problem. This is what I did (for those of
you who perhaps have a similar question):

Documents.Add Template:="\\SERVER01\templates\" &
selected, NewTemplate:=False, DocumentType:=0

Works like a charm!

Quote:
>-----Original Message-----
>I'm using a listbox to show all templates in a directory
>and want the user to be able to double click an item in
>the listbox (i.e. the desired template), which then
opens.
>I'm recording the value of the selected listbox item into
>a variable and want to insert that variable in the
>document.add line. I just don't know the exact way to do
>it. Who can help?! Thanks!

>The Code:

>Private Sub ListBox1_DblClick(ByVal Cancel As
>MSForms.ReturnBoolean)
>Dim selected As String
>selected = ListBox1.Value
>Documents.Add Template:="\\SERVER01\templates\[place
where
>the 'selected'-variable should go]", _
>        NewTemplate:=False, DocumentType:=0
>End Sub
>.



Sun, 31 Oct 2004 18:36:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Adding A Line To A Word Document Via VBA

2. VBA code adding 6 blank lines after adding pragraphs - Word 97

3. Adding variables to this line of code...

4. How to add a document to another document

5. Adding a document, then deleting that document

6. Textbox/label which add a new line and remove the last line

7. Adding Environmental Variable to System Variables thru VB

8. How to add UserDefined document?

9. adding office documents to a folder via code

10. How to add shapes to a word document

11. Office XP only: Spurious bookmark added to Word document Automating Powerpoint from Word

12. Adding a picture into a word document while doing a mail merge

 

 
Powered by phpBB® Forum Software