Problemer med ”server busy error dialog” og SaveAsDialog
Jeg har lidt problemer med en Windows SaveAsDialog.Jeg kalder dialogen via VBA6.5 i en solidworks Macro.
Macro’en virker så vidt fint på de fleste systemer, der er dog en undtagelse, nemlig ”Windows XP X64” i en 64 bit udgave af solidworks, det kun 64bit udgaven af solidworks giver problemer, 32bit udgaven virker fint i det samme operativsystem.
Problemet er at der efter ca. 7sek kommer en ”server busy error dialog” hvis jeg ignorere dialogen virker macroen stadig fint, det er bare irreterende at de på.
Jeg ved at der findes en Flag “SHAREAWARE” der skulle gøre at error dialoger vil blive ignoreret under runtime jeg har dog ikke haft meget hæld med at implementere denne.
Håber der er nogen Eksperter derude der kan hjælpe mig med dette problem.
Forneden ses den kode der styre dialogboksen samt tilbagemældingen til macroens Textbox
' Windows API to get the free discspace
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" ( _
ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long
' Windows API for the SaveAs Filebox
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" _
(pOpenfilename As OPENFILENAME) As Long
' structure needed by Windows API
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
’ Her kaldes SaveAs Dialogen
Dim NewFileStringLenth1 As Long
Dim NewFileStringName1 As String
Dim NewBSCPathNoExtension As String
Dim NEWFileName As String
Dim OFName As OPENFILENAME
Dim tmp As String
NEWFileName = m_Text.Text + " "
If Len(NEWFileName) > 255 Then
NEWFileName = Strings.Left(NEWFileName, 250)
End If
'Set the initial directory
OFName.lpstrInitialDir = m_Text.Text
'Set the structure size
OFName.lStructSize = Len(OFName)
'Set the filet
OFName.lpstrFilter = "PDF (*.pdf)" + Chr$(0) + "*.pdf" + Chr$(0) + "DWG (*.dwg)" + Chr$(0) + "*.dwg" + Chr$(0) + "eDrawing (*.edrw)" + Chr$(0) + "*.edrw" + Chr$(0) + "Drawing (*.slddrw)" + Chr$(0) + "*.slddrw" + Chr$(0) + "JPEG (*.jpg)" + Chr$(0) + "*.jpg" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
'Create a buffer
OFName.lpstrFile = Space$(254)
'Set the maximum number of chars
OFName.nMaxFile = 255
'Create a buffer
OFName.lpstrFileTitle = Space$(254)
'Set the maximum number of chars
OFName.nMaxFileTitle = 255
'Set the dialog title
'OFName.lpstrTitle = swPage.caption
'no extra flags
OFName.flags = OFN_SHAREAWARE
'default extension
OFName.lpstrDefExt = "PDF" + Chr$(0)
OFName.lpstrFile = NEWFileName
'Show the 'Save File'-dialog
If GetSaveFileName(OFName) Then
NewFileStringName1 = Trim$(OFName.lpstrFile)
OFName.lpstrInitialDir = NewFileStringName1
NewFileStringLenth1 = OFName.nFileExtension
NewBSCPathNoExtension = Strings.Left(NewFileStringName1, NewFileStringLenth1 - 1)
m_Text.Text = NewBSCPathNoExtension
End If