Hello,
Basically, I have a listbox in my userform and and table with same column and row of the listbox. My listbox items are from Sheet3 using a range source Sheet3(A1:c6). What I wanted to do is when I click the command button all the items in the Listbox will be transfer to my MS word table.
THis is my current code. Unfortunately, Nothings happening and I have no idea why. Need help.. =(
I have attached a sample image.
Basically, I have a listbox in my userform and and table with same column and row of the listbox. My listbox items are from Sheet3 using a range source Sheet3(A1:c6). What I wanted to do is when I click the command button all the items in the Listbox will be transfer to my MS word table.
THis is my current code. Unfortunately, Nothings happening and I have no idea why. Need help.. =(
I have attached a sample image.
VBA Code:
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open(DocFile, False)
Word.Application.Visible = True
For lnglistcount = 0 To ListBox1.List - 1
WordDoc.Content.InsertAfter Text:=ListBox1.List(lnglistcount)
WordDoc.ExportAsFixedFormat OutputFileName:=FilePath, ExportFormat:=wdExportFormatPDF
WordDoc.Close saveChanges:=False
WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing
MsgBox "File Created."
Next