Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2005, 10:58 AM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Browes directory and select file

I'm trying to write code to browes a directory and select a file.
The file is a plotstyle for AutoCAD. The application I'm trying to
make is for printing drawings.
I'm using the common dialog box. Can anyone help.
I'm new in VB and still struggling in the basic areas.
Thanks

 
Old January 23rd, 2005, 12:33 PM
Authorized User
 
Join Date: Jan 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'Here ya go

' Ok start a new project add the common dialog control add a command button
' Add a text box and paste in this code into VB then hit F5 click the button

Private Sub Command1_Click()
On Error GoTo OpenErr:

    With CommonDialog1
        .CancelError = True ' turn on error checking
        .DialogTitle = "Open AutoCAD" ' dialog title
        .Filter = "AutoCAD Files(*.txt)|*.txt|" ' I used txt because I don;t know the fileExt
        .ShowOpen ' show open dialog
        If Len(.FileName) = 0 Then Exit Sub ' do nothing if length is zero

        If Not Right(.FileName, 3) = "txt" Then ' remmber to replace txt with the AutoCAD FileExt
            MsgBox "Not a vaild AutoCAD File", vbInformation, "inavild File"
            Exit Sub
        Else
            ' do what ever here
            Text1.Text = .FileName
        End If

    End With

    Exit Sub

OpenErr:
    If Err = cdlCancel Then Err.Clear
End Sub

When ya dreams come true.
 
Old September 21st, 2007, 02:24 AM
Registered User
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I have the same problem but a little more advanced:
I select the file an that stuff but I'm not able to set the file as the main .ctb file so if someone could help me I'll appreciate it very much.
Thanks

PS: The code I'm using to set the file is:
Code:
AcadApplication.ActiveDocument.Application.Preferences.Output.DefaultPlotStyleTable = frmPlotear.txtCTB.Text
'frmPlotear.txtCTB.Text is the path to the file
 
Old September 21st, 2007, 11:59 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What is the result of this code running?
 
Old September 25th, 2007, 02:56 AM
Registered User
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by BrianWren
 What is the result of this code running?
It doesn't take the .ctb file I select, if the .pc3 file has a .ctb attached uses that, but if it hasn't it doesn't select any .ctb file

 
Old September 26th, 2007, 02:07 AM
Registered User
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Maybe if I write all the function code it will be easyer to view the problem

Code:
If frmPlotear.chkZoom.Value Then AcadApplication.ZoomExtents

'"Ninguno" is equal to "None" but it doesn't work with "None" because the AutoCAD version is in spanish, I guess so 
If frmPlotear.txtPC3.Text <> "Ninguno" Then
        AcadApplication.ActiveDocument.Application.Preferences.Output.DefaultOutputDevice = frmPlotear.txtPC3.Text
End If

AcadApplication.ActiveDocument.Application.Preferences.Output.DefaultPlotStyleTable = frmPlotear.txtCTB.Text

Resultado = AcadApplication.ActiveDocument.Plot.PlotToFile(Left(FichDWG, Len(FichDWG) - 4))


 
Old September 26th, 2007, 11:35 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Well, you didn't actually answer my question. You told me what it doesn't do, in non-technical terms, but you didn't say what it does do.

But perhaps AutoCAD requires a .pc3 file for this property—period. If that's the caes, then you are up
against a constraint coded into the guts of AutoCAD.

Further, if this is accurate, then you need to 1) trap for errors regarding the file extension, and
2) guarantee that AutoCAD is never fed anything other than *.pc3 for this propery.
 
Old September 27th, 2007, 01:56 AM
Registered User
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, sorry about the misunderstanding
What the code does is plotting the drawings (.dwg files) into .plt files without giving any kind of error.
In other function the .plt files are plotted in a printer, and then is when I realized that the .ctb file I give is not used.

The DefaultPlotStyleTable property sets a .ctb file (giving the full path) and the DefaultOutputDevice sets a .pc3 file (giving the file name), both used for plotting.

Thank you for your time






Similar Threads
Thread Thread Starter Forum Replies Last Post
File Directory Access ra7207 VB.NET 1 June 20th, 2006 01:45 PM
Generated file not in directory ... :( bebe XML 2 August 11th, 2005 08:48 AM
create xsl file in c directory keyvanjan Classic ASP Basics 2 June 21st, 2005 04:52 PM
Q. How do I upload a file to a directory? richard.york PHP FAQs 0 April 8th, 2004 05:47 AM
file/directory iteration nbryson C# 5 August 1st, 2003 05:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.