Author Topic: Need help with initial directory  (Read 1153 times)

0 Members and 1 Guest are viewing this topic.

Eloquintet

  • Gator
  • Posts: 3206
Need help with initial directory
« 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
Dan

AutoCAD Architecture 2015

Bryco

  • Water Moccasin
  • Posts: 1851
Re: Need help with initial directory
« Reply #1 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?

LE

  • Guest
Re: Need help with initial directory
« Reply #2 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

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16828
  • Superior Stupidity at its best
Re: Need help with initial directory
« Reply #3 on: October 24, 2007, 06:57:19 PM »
Luis, that should work ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Eloquintet

  • Gator
  • Posts: 3206
Re: Need help with initial directory
« Reply #4 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
Dan

AutoCAD Architecture 2015

Eloquintet

  • Gator
  • Posts: 3206
Re: Need help with initial directory
« Reply #5 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?
Dan

AutoCAD Architecture 2015

Guest

  • Guest
Re: Need help with initial directory
« Reply #6 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??

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16828
  • Superior Stupidity at its best
Re: Need help with initial directory
« Reply #7 on: October 27, 2007, 12:32:24 PM »
What is the method you are using for loading the macro?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie