I had a function that received 6 variables.
The one I changed in the function was an integer.
When the function returned, that integer was unchanged.
I changed the function to a sub and same result.
Function x(Var1 as Object, Var2 as Object, Var3 as Object, Var4 as string, Var5 as integer, Var6 as string) as integer
called as sf=x(Var1, Var2, Var3, Var4, Var5, Var6)
the function set Var5 to some value (9, 2, or 5)
I check the value of Var5 before I called the function and after, and Var5 is unchanged.
I even made Var5 a Global. No change.
Function is not BYVALUE and as I understand, by reference.
I also tried to make Var5 STATIC, but no change.
Any help would be appreciated.
Here is the sub:
Private sub Sheetfind(mydoc as object, sheetDoc as object, foundsheet as object, tripit as INTEGER, xSheet as string, sheetline as string, sf as integer)
' we are to find the sheet named xsheet
' we go to the setup and find where it is by the line# sheetline
' if in this workbook, then we just set sheettripit to 2 and ensure we use mydoc and use foundsheet as xsheet
'if in another workbook, then we set sheettrip to 9 and load the worksheet
dim path as string
dim sURL as string
dim Components as variant
dim CompEnum as variant
dim OneComp as variant
sf=9
dim Prop(0) as New com.sun.star.beans.PropertyValue
' sheet5 = COA
path=mydoc.Sheets.getByName("Setup-POS").getCellRangeByName(sheetline).String 'get location of sheet
if LCase(left(path,4))="this" then 'here we check to see if the sheet exists in workbook
If mydoc.Sheets().hasByName(xSheet) Then
tripit=2
sf=1
foundsheet=myDoc.Sheets.getByName(xSheet)
msgbox "6sheettripit= " & tripit
exit sub
else
msgbox "NO " & xsheet & " file! -this must be created first!"
sf=3
exit sub
end if
else
If Not FileExists(path) Then
msgbox "NO " & xSheet & " file! -this must be created first!"
sf=3
exit sub
end if
'here we check if the file is already open and if it is, we set sheetDoc to it
if FileOpen2(path) then
' msgbox "Here" & path
sURL = convertToURL(path)
Components = StarDesktop.getComponents()
CompEnum = Components.createEnumeration
While CompEnum.hasMoreElements
OneComp = CompEnum.nextElement
If OneComp.URL = sURL Then
sheetDoc = OneComp ' set sheetdoc to the file
foundsheet = sheetDoc.Sheets.getByName(xSheet) 'get the sheet xsheet
foundsheet.IsVisible = True 'view the sheet
tripit=2
sf=2
msgbox "opentripit= " & tripit
exit sub
End If
Wend
else
sUrl = convertToURL(path) ' set path from above and open the workbook which contains the customer worksheet
if fileExists(sUrl) then
Prop(0).Name = "Hidden" 'the document will open hidden"
Prop(0).Value = False
sheetDoc = stardesktop.LoadComponentFromURL(sUrl, "_default", 0, Prop()) 'open file
foundSheet = sheetDoc.Sheets.getByName(xsheet) 'get the sheet named xsheet
tripit=9
sf=5
msgbox "Newtripit= " & tripit
exit sub
else
msgbox "NO " & xsheet & " file! -this must be created first!"
msgbox "3tripit= " & tripit
sf=3
exit sub
end if
end if
end if
msgbox "escapetripit= " & tripit
end sub