Bladezy Posted April 18, 2013 Posted April 18, 2013 hi guys, Im trying to insert a block into autocad, via a button/ check box. my code is as follows:- Private Sub OptionButton1_Click() Dim insertion point (0 to 2) as double Dim blockrefobj As AcadBlockReference InsertionPnt(0) = 0 : insertionPnt(1) = 1 : insertionPnt(2) = 0 'insert the block ' modify drawing and path name as nessesary for your system. Set blockrefobj = ThisDrawing.Paperspace.InsertBlock(insertionPnt, "C:\Users\bladest\Desktop\vba\new block1345.dwg", 1, 1, 1, 0)) 'in r14, no Z-scale required Zoomall() 'in r14, use ThisDrawing.ActiveViewport.ZoomAll End Sub I get a 'syntax error', 'identifier expected' followed by 'statement is not valid in a namespace' could anyone please trouble shoot this for me? it would be much appreciated obviously once i get this code working, i will be able to apply it to multiple blocks? am i correct in saying this? cheers forum. Quote
dbroada Posted April 19, 2013 Posted April 19, 2013 firstly, you will get told off by one of the moderators for not using code tags. Hit on the # tool and put your lines of code between the tags.. next, you have declared your variable with the Dim statement incorrectly in that there shouldn't be a space, and then you used it differently in the code. These two lines should be identical. Dim insertion point (0 to 2) as double InsertionPnt(0) = 0 : insertionPnt(1) = 1 : insertionPnt(2) = 0 Dim [color=red]InsertionPnt[/color] (0 to 2) as double [color=red]InsertionPnt[/color](0) = 0 : [color=red]insertionPnt[/color](1) = 1 : [color=red]insertionPnt[/color](2) = 0 if you start the VBA module with Option Explicit you will get a syntax error if you try to use a varaible that you haven't declared. This is a good thing. It would have shown up the above errors immediately. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.