Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert text to table

Status
Not open for further replies.

wmbb

Technical User
Jul 17, 2005
320
NL
I'm using the WORD version 2007 and 2010.
I've recorded the following macro part:
Code:
    Selection.WholeStory
    WordBasic.TextToTable ConvertFrom:=1, NumColumns:=3, NumRows:=13, _
        InitialColWidth:=wdAutoPosition, Format:=0, Apply:=1184, AutoFit:=1, _
        SetDefault:=0, Word8:=0, Style:="Table Grid"
    Selection.Tables(1).Style = "tbl Personal 1"
    Selection.WholeStory.Copy

This doesn't give the possibility to give any user control because it doesn't show up a dialog as seen by the creation of the macro.
Is there a possibility to show the dialog so user can change some options if they want before converting the text to a table ?
 


hi,

Well, doesn't the user need to select the text that he/she wants to convert?

Then put a button in the Ribbon to run the macro.

I don't think that telepathy will translate.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Have a look at the Application.Dialogs(wdDialogTextToTable) object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Actually this will be a part of a macro.
First the macro creates a tab separated text.
Subsequently this text is selected using Selection.WholeStory
I want to convert this text in a table and format the table with defined style.
Because the number of columns is variable I need the dialog to popup so the user can define the number of columns.
In the recorded part the macro always creates 3 columns.
That's the reason why I need the dialog...

 

I got you. I followed the dialog and found the reason.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Okay, the code below works like I want but how to set default settings in this dialog ?

Code:
Selection.WholeStory
Application.Dialogs(wdDialogTextToTable).Show
 

Check out Built-in Dialog Box Argument Lists in VBA Help


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


You do realize that the dialog code detects the selected text and makes assumptions based on that selection for several of the arguments.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi Skip,

Yes I realize that and that is good but I want to set the AutoFitBehavior to AutoFitContent as default but I can't get working.
So help is wanted from guys like you !

Thanks in advance...
 


Turn on your MACRO RECORDER and have at it. You will have your answer.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi Skip,

This was already done, see my first post...
In this script I can't find how to put the default AutoFitBehavior to AutoFitContent ?!
 
It's unfortunate that the macro recorder generates that WordBasic statement. Use, instead, the [blue][tt]Range.ConvertToTable[/tt][/blue] method and you should be able to set whatever options you want

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Would that not only work as a direct instruction affecting the Range? Does the OP not want to set an option in the dialog?

 
'twas just a suggestion :)

I'm having a hard job imagining the whole thing. A macro creates tab-delimited text (sourced from somewhere) yet cannot keep track of what its doing well enough to know how many columns to create in a table it makes of the data after the event.



Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
I'm having a hard job imagining the whole thing."


Me too.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top