Creating Macro in Visio 2007

  • Thread starter Puzzled MS User
  • Start date
P

Puzzled MS User

I want to record a macro in Visio 2007 to paste unformatted text (Paste
Special > Unformatted Text). I can record it okay and assign to the keyboard
but it won't work if I try to use it? I have tried to edit the macro with
the VB mark-up using a similar macro created in MS Word:

Sub PasteText()
'
' PasteText Macro
On Error GoTo ErrorHandler
Selection.PasteSpecial DataType:=wdPasteText
Exit Sub
ErrorHandler:
Beep
End Sub

But this just gives an error beep.

Also - how do I do the following:

1) Create it so it works on all Visio documents not just the one I'm in when
recording it?
2) Assign it to a toolbar button (I have tried to Customise toolbars but
there is no option to add a macro and I can't move it from "Tools > Macro >
NewMacro > PasteText" as only an option appears for Macro List rather than
the actual list of macros?

Any help is appreciated.
 
A

AlEdlund

The first one sounds like security is set to not allow macros to run.

"1) Create it so it works on all Visio documents not just the one I'm in
when
recording it?" Save the blank drawing (with the macro) as a template and
call it as your standard document.

"2) Assign it to a toolbar button (I have tried to Customise toolbars but
there is no option to add a macro and I can't move it from "Tools > Macro >
NewMacro > PasteText" as only an option appears for Macro List rather than
the actual list of macros?" That also has to be accomplished with custom
code,

http://msdn.microsoft.com/en-us/library/aa245244(office.10).aspx

al
 
P

Puzzled MS User

I just checked the security settings and it was on "Disable all macros with
notification" (I didn't get a notification when trying to use macro), so I
changed it to "Enable all macros" but it still didn't work. When I view the
macro in VBA mode it only has:

Sub PasteText()
'
' Paste Unformatted Text
'
' Keyboard Shortcut: Ctrl+Shift+G
'
End Sub

Paste Unformatted Text is the description I gave it so it appears to not be
recording anything. Do you know what the coding should be to Paste Special >
Unformatted Text?

I tried to use that link you gave but I couldn't understand where I was
supposed to look as it just took me to the contents page. I scanned the
Chapter 15 section on Programming Visio with VBA?? but most of it is geared
towards creating macros for shapes etc.

Any other help would be greatly appreciated.

Thanks
 
A

AlEdlund

The macro you are attempting to emulate, pastes text into a selection in
word. Visio has a lot more options on where you might paste text...
Consider this...
Open VBA
Select Microsoft Visual Basic help
' why you have to come to the vba tool to find this is beyond me
Select Visio Automation Object Model Reference
Enter Paste Text in search pane

al
 
P

Puzzled MS User

Just to address your post this is what I was trying to do: I have visio pages
full of shapes/text boxes that all link wonderfully as a conceptual map (in
different colours/fonts, etc.) but I want to copy the text from the boxes
onto another page in a vertical outline format, without having to go Paste
Special > Unformatted Text > OK, all the time. I tried to record a macro
using the simple record, perform the steps, stop button action (without using
VBA as you can clearly tell I'm no good at it), but when it comes to using
the macro, nothing happens.

I recorded a similar macro in MS Word and for some reason MS/Macro tool??
didn't acknowledge the "unformatted text" option being selected and kept
pasting the format, so I jumped onto these forums and some lovely MVPs
provided the VBA language and instructions on how to edit the macro to make
the unformatted text macro work... all good. I thus tried to replicate the
similar action in MS Visio (silly me thought all MS programs were
similar...), but when I edited the macro I noticed there was nothing within
it - thus why the macro didn't work. I tried to use the Word VBA as you
noticed but as I said, it didn't work and I wanted to ask what the Visio
equivalent was. I'm assuming you don't know and the help links you gave me
are not helping either.

As I'm writing this, I'm now thinking the outline would be better in
Word/Excel - which I know how to use and have set up macros which work. I
just added this post to address the "why you have to come to the vba tool to
find this is beyond me" comment you noted below.

Have a nice day and thanks for trying...
 
A

AlEdlund

Given that piece of insight I'd probably have suggested that you consider
looking at the tools function and see if one of the prebuilt report options
might have helped. The reason I say that is that is because the process
you're attempting appears at the surface to have an implied 'append to
existing text' impact that I did not understand from you original post.

al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top