Want "apply" in options using vba.

Want "apply" in options using vba.

Anonymous
Not applicable
445 Views
10 Replies
Message 1 of 11

Want "apply" in options using vba.

Anonymous
Not applicable
A co-worker has created vba macro that will change the "plot style table search path" The problem is when we change this using vba the ctb is not recognized (ie it plots in color instead of mono). If we change the path manually it recognizes the ctb. It seems to have something to do with the apply button in options. How do we get vba to apply/reinitilize or whatever it has to do in vba. Is there a command to do this. Thanks
0 Likes
446 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
For an accurate answer, you should post the code. Since you haven't done
that, try adding .RefreshPlotDeviceInfo to the plot configuration
object.
___________________________
Mike Tuersley
AutoCAD Clinic
Rand IMAGINiT Technologies
0 Likes
Message 3 of 11

Anonymous
Not applicable
Hopefully, Mike's answer will work for you. If not...

I don't know if this will work for you, but I had a similar situation. In
my case, Page Setup options wouldn't apply until the Page Setup dialog box
was run. I added code to call up the dialog box and just hit OK. Here's
that code, changed to work with the Options dialog box. It doesn't run the
Apply button, and it might not even open up on the right tab, but maybe
OK'ing the dialog will do the job for you?

SendKeys "{ENTER}"
Thisdrawing.SendCommand ("options" & vbCr)

I don't know if people will be able to cause problems with your program by
smacking a bunch of keys while it runs, but I haven't had any problems with
this yet.

James
0 Likes
Message 4 of 11

Anonymous
Not applicable
Here is the code. The last two line were the suggestion of next post. It actually works but we have to hit okay to get out of option. Any comments would be grateful.


Private Sub CaddStandards_Click()
'This button modifies the preference which controls
' the location for plot style table path files(ctb) - to Q:\Plotting\Plot Styles (ctb)
Dim ACADPref As AcadPreferencesFiles
Dim NewValue As String
Dim AcadPlotConfiguration As Variant
' Get the files preferences object
Set ACADPref = ThisDrawing.Application.Preferences.Files
'change the path to the CADD Standards directory
NewValue = "Q:\Plotting\Plot Styles (ctb)"
ACADPref.PrinterStyleSheetPath = NewValue
Unload Me
MsgBox "The PrinterStyleSheetPath (ctb) path has been set to: " & NewValue

SendKeys "{enter}"
ThisDrawing.SendCommand "options " & vbCr

End Sub
0 Likes
Message 5 of 11

Anonymous
Not applicable
We tried your solution. We still have to hit okay to get out of the options dialoge. Is there no way to get out of dialog? It does cure the problem of the ctb not being recognized. The code is posted above. Thanks.
0 Likes
Message 6 of 11

Anonymous
Not applicable
1) you need to remove the space after options... i.e. "options" instead of
"options ". When I do this, the options dialog box doesn't stay... in fact,
I don't even see it blink. So you will have to check it to see if it's
actually running the dialog box or just skipping it. The extra space was
making

2) I searched this NG and apparently someone else found that the SendKeys
doesn't work for this dialog box. The only solution they listed had to be
done from standalone VB. Here's the link:

http://hem.fyristorg.com/cadman/autocadbugs.htm#Profiles

Good luck,
James
0 Likes
Message 7 of 11

Anonymous
Not applicable
We removed the space and it worked great. Not sure what happend because he cut/pasted right of this board? Anyways thanks for your help.
0 Likes
Message 8 of 11

Anonymous
Not applicable
I spoke too soon. It works great if the last tab accessed in options is "file". Otherwise it does not update if some other tab is current. We looked at your point 2, but we do not have the brain power to figure out how to accomplish this. Any suggestions on how we can get the "file" tab to be the current one?
Thanks for your help.
0 Likes
Message 9 of 11

Anonymous
Not applicable
I think you can do this, if you're comfortable changing a registry key. You
could keep this as simple as a line or two, or get more complicated if you
wanted more robust code. It looks like there's some code you can borrow in
the links below.

Steps...
1) get name of registry key. Simple approach: use REGEDIT to find key,
hard-wire this key name. Robust approach: see second link below, involves
AcadX.arx.
2) set the key value corresponding to "Files" tab -- on my machine it's 0
3) OPTIONS in ACAD should now open to Files

The main part of this (long) link that would be useful to you is the part
about the ActiveTab in the Options dialog:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=9982E1F9
C001696686C095F8E5D936B2%40in.WebX.maYIadrTaRb&rnum=1&prev=/groups%3Fhl%3Den
%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Doptions%2Bdialog%2Btab%26meta%3Dgro
up%253Dautodesk.autocad.customization.vba

According to this one, if you want your code to work for more than one
version of ACAD (i.e. ACAD 2004, Mech Desktop, etc) you will need to load
and use AcadX.arx to get the ProductKey. You could simplify your code by
just hard-wiring in a specific version of ACAD... that would last you until
your company upgrades. Whether this is sat probably depends on how many
people are going to be using your program.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=E1051672
39443452289A1A4CA86AA92B%40in.WebX.maYIadrTaRb&rnum=9&prev=/groups%3Fhl%3Den
%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Doptions%2Bdialog%2Btab%26meta%3Dgro
up%253Dautodesk.autocad.customization.vba

Here's the Google search these links came from.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=options+dialog
+tab&meta=group%3Dautodesk.autocad.customization.vba

One slight cautionary note... it's not a good practice to put erroneous info
into the Registry, so test your code before you actually make registry
changes... i.e. msgbox your variables for key names and values.

Good luck, keep us informed....

James
0 Likes
Message 10 of 11

Anonymous
Not applicable
Thanks for your reply James. I found the place in regester using regedit. I can change the "Files" tab to 0. How do I hard-wire this key name? Or is it more complicated?
0 Likes
Message 11 of 11

Anonymous
Not applicable
Sorry... I don't have much more time to give to this right now, I'm pretty
swamped.

Be careful in REGEDIT... don't change Data values that you are unfamiliar
with...

But here's a link to various ways of using the API to change registry
settings. Maybe other people on this list have code pieces which will
*safely* change the value of a single key
([HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\ACAD-103:409\Profiles\<<
MCAD>>\Dialogs\OptionsDialog\ActiveTab, of type REG_DWORD] on my computer.
I really wouldn't think this should take more than 5 or 10 lines of code,
including enough error-checking to make sure you wouldn't corrupt your
registry. (Experts... this isn't a careless statement, is it?)

(long link)
http://www.planet-source-code.com/vb/scripts/BrowseCategoryOrSearchResults.a
sp?lngWId=1&B1=Quick+Search&txtCriteria=registry+api&blnWorldDropDownUsed=TR
UE&txtMaxNumberOfEntriesPerPage=100&blnResetAllVariables=TRUE&optSort=Alphab
etical

I wish I could be of more help right now...

James
0 Likes