|
|
|
date: Fri, 16 Nov 2007 11:19:00 -0800,
group: microsoft.public.word.vba.beginners
back
Re: Macro doc + toolbar button via Email?
I have discovered a slight problem with this macro - this is the code, it is
meant to cut one selected table out whilst putting another in by means of an
assigned toolbar button.
Sub pastetable()
If Selection.Information(wdWithInTable) Then
Selection.Cut
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2,
NumColumns:= _
5, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
Selection.TypeText Text:="this"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="is"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="the"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="example"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="This"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=4
Selection.TypeText Text:="is"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="example"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="of"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="macro"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="working"
Else
MsgBox "Please select a table."
End If
This is the error I am getting,
"The method or property is not available because the object is empty".
Now, if the cursor happens to be before or after the table, and the macro
button is pressed then the message box appears fine. But, if the cursor
happens to be in a table cell, and the macro button is pressed, then I get
the error message above. Any ideas how I can fix it.
Thanks
End Sub
"Doug Robbins - Word MVP" wrote:
> See the article "Distributing macros to other users" at:
>
> http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "elle0612" wrote in message
> news:CD018784-2F16-4AAA-935D-24DC5355048E@microsoft.com...
> > Yes, I know most of that (not sure what Organizer is though).
> >
> > Its true it was a document I sent not a template, but I was hoping the
> > document would open for the receiver without having to fiddle with trying
> > to
> > attach buttons themselves.
> >
> > This document was an example of something that will end up as a template
> > in
> > the future, I didn't think I would have to do that at this stage.
> >
> > thanks
> >
> > "Summer" wrote:
> >
> >> It seems neither do you! - The document needs to be xxxx.dot template
> >> with
> >> the macro attached to the vbe editor ALT F11 and the toolbar copy using
> >> Organizer and attached to the template document.
> >>
> >> The receiver needs to save as xxxx.dot onto their desktop and then right
> >> click NEW and create a copy which should with reference to the xxxx.dot
> >> template you sent and the macros....
> >>
> >> Hope this helps....
> >> "elle0612" wrote in message
> >> news:E9BFECB8-6FF9-46E7-ADF0-2AA917FDFCF0@microsoft.com...
> >> > Hi
> >> >
> >> > I'm wondering if it is possible to Email a document with a macro
> >> > attached,
> >> > to arrive at receiver complete with macro button on tool bar to run it.
> >> >
> >> > I need to send someone the document and they don't know anything about
> >> > attaching buttons to macros.
> >> >
> >> > Thanks
> >>
> >>
> >>
>
>
>
date: Wed, 21 Nov 2007 15:15:00 -0800
author: elle0612
Re: Macro doc + toolbar button via Email?
Question re-posted in another message thread.
<http://groups.google.com/group/microsoft.public.word.vba.beginners/browse_t
hread/thread/ab5b1e2b19d19d9a/62fb1b7ce765c3ab>
> I have discovered a slight problem with this macro - this is the code, it is
> meant to cut one selected table out whilst putting another in by means of an
> assigned toolbar button.
>
>
> Sub pastetable()
>
> If Selection.Information(wdWithInTable) Then
>
> Selection.Cut
>
> ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2,
> NumColumns:= _
> 5, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
> wdAutoFitFixed
> With Selection.Tables(1)
> If .Style <> "Table Grid" Then
> .Style = "Table Grid"
> End If
> .ApplyStyleHeadingRows = True
> .ApplyStyleLastRow = True
> .ApplyStyleFirstColumn = True
> .ApplyStyleLastColumn = True
> End With
> Selection.TypeText Text:="this"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="is"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="the"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="example"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="This"
> Selection.MoveDown Unit:=wdLine, Count:=1
> Selection.MoveLeft Unit:=wdCharacter, Count:=4
> Selection.TypeText Text:="is"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="example"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="of"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="macro"
> Selection.MoveRight Unit:=wdCell
> Selection.TypeText Text:="working"
>
> Else
> MsgBox "Please select a table."
> End If
>
> This is the error I am getting,
>
> "The method or property is not available because the object is empty".
>
> Now, if the cursor happens to be before or after the table, and the macro
> button is pressed then the message box appears fine. But, if the cursor
> happens to be in a table cell, and the macro button is pressed, then I get
> the error message above. Any ideas how I can fix it.
>
> Thanks
>
>
> End Sub
> "Doug Robbins - Word MVP" wrote:
>
>> See the article "Distributing macros to other users" at:
>>
>> http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm
>>
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "elle0612" wrote in message
>> news:CD018784-2F16-4AAA-935D-24DC5355048E@microsoft.com...
>>> Yes, I know most of that (not sure what Organizer is though).
>>>
>>> Its true it was a document I sent not a template, but I was hoping the
>>> document would open for the receiver without having to fiddle with trying
>>> to
>>> attach buttons themselves.
>>>
>>> This document was an example of something that will end up as a template
>>> in
>>> the future, I didn't think I would have to do that at this stage.
>>>
>>> thanks
>>>
>>> "Summer" wrote:
>>>
>>>> It seems neither do you! - The document needs to be xxxx.dot template
>>>> with
>>>> the macro attached to the vbe editor ALT F11 and the toolbar copy using
>>>> Organizer and attached to the template document.
>>>>
>>>> The receiver needs to save as xxxx.dot onto their desktop and then right
>>>> click NEW and create a copy which should with reference to the xxxx.dot
>>>> template you sent and the macros....
>>>>
>>>> Hope this helps....
>>>> "elle0612" wrote in message
>>>> news:E9BFECB8-6FF9-46E7-ADF0-2AA917FDFCF0@microsoft.com...
>>>>> Hi
>>>>>
>>>>> I'm wondering if it is possible to Email a document with a macro
>>>>> attached,
>>>>> to arrive at receiver complete with macro button on tool bar to run it.
>>>>>
>>>>> I need to send someone the document and they don't know anything about
>>>>> attaching buttons to macros.
>>>>>
>>>>> Thanks
>>>>
>>>>
>>>>
>>
>>
>>
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
date: Fri, 23 Nov 2007 18:57:47 -0500
author: Russ LID
|
|