TheSwamp

Code Red => VB(A) => Topic started by: Eloquintet on October 24, 2007, 09:35:04 AM

Title: Need help with initial directory
Post by: Eloquintet on October 24, 2007, 09:35:04 AM
Hey guys,

I got a program that works fine except I just want the initial directory to be Autosave. I know this is probably easy but I can't seem to figure out how to change it to work here. Can somebody help me out?


Code: [Select]
Public Function GetFileOpen(Title As String, InitFolder As String, Filter As String) As String
  Dim OpenFile As OPENFILENAME
  Dim lReturn As Long
  Dim sFilter As String
  With OpenFile
    .hwndOwner = ThisDrawing.hWnd
    .lStructSize = Len(OpenFile)
    .lpstrFilter = Filter
    .nFilterIndex = 1
    .lpstrFile = String(257, 0)
    .nMaxFile = Len(OpenFile.lpstrFile) - 1
    .lpstrInitialDir = InitFolder
    .lpstrFileTitle = OpenFile.lpstrFile
    .nMaxFileTitle = OpenFile.nMaxFile
    .lpstrTitle = "Select File"
    .flags = 4
    .lpTemplateName = "Test"
  End With
  '
  lReturn = GetOpenFileName(OpenFile)
  If lReturn = 0 Then
    GetFileOpen = ""
  Else
    GetFileOpen = Left$(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, Chr$(0)) - 1)
  End If
End Function
Title: Re: Need help with initial directory
Post by: Bryco on October 24, 2007, 10:00:36 AM
Quote
I just want the initial directory to be Autosave
I don't quite get what you are asking.
The code that you posted, does that give you the name of an open dwg or any dwg?
Title: Re: Need help with initial directory
Post by: LE on October 24, 2007, 10:20:51 AM
No idea.... but:

Code: [Select]
    .lpstrInitialDir = InitFolder

To:

Code: [Select]
    .lpstrInitialDir = ThisDrawing.GetVariable("SAVEFILEPATH")

and remove the argument 'InitFolder As String from the function

? ? ?

wait for the vb/a masters
Title: Re: Need help with initial directory
Post by: Keith™ on October 24, 2007, 06:57:19 PM
Luis, that should work ...
Title: Re: Need help with initial directory
Post by: Eloquintet on October 25, 2007, 09:27:46 AM
basically the routine allows you to open bak files then saves them as dwg files and as I would mostly use this to recover autosaves i want it to start there make sense. i'll give it a try and let you know. thanks everybody
Title: Re: Need help with initial directory
Post by: Eloquintet on October 25, 2007, 09:45:58 AM
Hey,

I got the routine working but when I try to Autoload it as I do all of my other vba routines it gives me this error upon loading

error: bad character read (octal): 21

and if i run it it says macro not found

but if i manually load it it runs fine

What does this error mean?
Title: Re: Need help with initial directory
Post by: Guest on October 25, 2007, 11:42:56 AM
A quick search on Google suggests that there might be some goofy characters (maybe a linefeed or return or something like that) gumming up the works in your program.

What happens if you click on DEBUG --> COMPILE?  Does it find anything out of the ordinary??
Title: Re: Need help with initial directory
Post by: Keith™ on October 27, 2007, 12:32:24 PM
What is the method you are using for loading the macro?